From 36618668fc40325a322f9759d19924d309820e90 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 10 Jun 2013 18:10:21 +0200 Subject: [PATCH 01/35] fix typo --- composer.lock | 40 +++++++++++++------------- core/lib/Thelia/Command/CacheClear.php | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.lock b/composer.lock index a7322090a..e44a6a7e0 100644 --- a/composer.lock +++ b/composer.lock @@ -76,7 +76,7 @@ "authors": [ { "name": "Anthony Ferrara", - "email": "ircmaxell@ircmaxell.com", + "email": "ircmaxell@php.net", "homepage": "http://blog.ircmaxell.com" } ], @@ -488,17 +488,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.2.1", + "version": "v2.2.2", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "v2.2.1" + "reference": "v2.2.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.2", + "reference": "v2.2.2", "shasum": "" }, "require": { @@ -589,17 +589,17 @@ }, { "name": "symfony/http-foundation", - "version": "v2.2.1", + "version": "v2.2.2", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "v2.2.1" + "reference": "v2.2.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.2", + "reference": "v2.2.2", "shasum": "" }, "require": { @@ -635,7 +635,7 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2013-04-06 10:15:43" + "time": "2013-05-27 14:47:40" }, { "name": "symfony/http-kernel", @@ -708,17 +708,17 @@ }, { "name": "symfony/routing", - "version": "v2.2.1", + "version": "v2.2.2", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "v2.2.1" + "reference": "v2.2.2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.1", - "reference": "v2.2.1", + "url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.2", + "reference": "v2.2.2", "shasum": "" }, "require": { @@ -762,7 +762,7 @@ ], "description": "Symfony Routing Component", "homepage": "http://symfony.com", - "time": "2013-03-23 12:03:22" + "time": "2013-05-10 16:49:00" }, { "name": "symfony/yaml", @@ -819,12 +819,12 @@ "source": { "type": "git", "url": "https://github.com/fzaninotto/Faker.git", - "reference": "fac6c177c87bb5d10d256d9caa6933046fbac999" + "reference": "v1.2.0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fac6c177c87bb5d10d256d9caa6933046fbac999", - "reference": "fac6c177c87bb5d10d256d9caa6933046fbac999", + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/v1.2.0", + "reference": "v1.2.0", "shasum": "" }, "require": { @@ -833,7 +833,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -857,7 +857,7 @@ "faker", "fixtures" ], - "time": "2013-05-31 17:07:37" + "time": "2013-06-09 18:05:57" } ], "aliases": [ diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index dbb789323..eba228da8 100644 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -55,7 +55,7 @@ class CacheClear extends ContainerAwareCommand try { $fs->remove($cacheDir); - $output->writeln("cache clear successfully"); + $output->writeln("cache cleared successfully"); } catch(IOException $e) { $output->writeln(sprintf("error during clearing cache : %s", $e->getMessage())); } From 80380878f598ffcfdd821533b106982a4ddb8355 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 26 Jun 2013 14:45:19 +0200 Subject: [PATCH 02/35] changes tests create argument helpers start loop auto pagination --- .../Thelia/Core/Template/Element/BaseLoop.php | 16 +++- .../Core/Template/Loop/Argument/Argument.php | 42 ++++++++++ .../Loop/Argument/ArgumentCollection.php | 18 +++- .../Thelia/Core/Template/Loop/Category.php | 84 ++++--------------- .../Template/Smarty/Plugins/TheliaLoop.php | 12 +-- ...entTest.php => ArgumentCollectionTest.php} | 10 +-- core/lib/Thelia/Tests/Type/AnyTypeTest.php | 40 +++++++++ core/lib/Thelia/Tests/Type/EnumTypeTest.php | 43 ++++++++++ core/lib/Thelia/Tests/Type/FloatTypeTest.php | 42 ++++++++++ .../lib/Thelia/Tests/Type/IntListTypeTest.php | 42 ++++++++++ core/lib/Thelia/Tests/Type/IntTypeTest.php | 42 ++++++++++ core/lib/Thelia/Tests/Type/JsonTypeTest.php | 41 +++++++++ .../{TypeTest.php => TypeCollectionTest.php} | 53 ++---------- 13 files changed, 352 insertions(+), 133 deletions(-) rename core/lib/Thelia/Tests/Core/Template/Loop/Argument/{ArgumentTest.php => ArgumentCollectionTest.php} (95%) create mode 100755 core/lib/Thelia/Tests/Type/AnyTypeTest.php create mode 100755 core/lib/Thelia/Tests/Type/EnumTypeTest.php create mode 100755 core/lib/Thelia/Tests/Type/FloatTypeTest.php create mode 100755 core/lib/Thelia/Tests/Type/IntListTypeTest.php create mode 100755 core/lib/Thelia/Tests/Type/IntTypeTest.php create mode 100755 core/lib/Thelia/Tests/Type/JsonTypeTest.php rename core/lib/Thelia/Tests/Type/{TypeTest.php => TypeCollectionTest.php} (62%) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 519aae4bd..821055204 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -26,6 +26,7 @@ namespace Thelia\Core\Template\Element; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; /** * @@ -44,6 +45,14 @@ abstract class BaseLoop */ public $dispatcher; + protected function getDefaultArgs() + { + return array( + Argument::createIntTypeArgument('offset'), + Argument::createIntTypeArgument('limit'), + ); + } + /** * @param \Symfony\Component\HttpFoundation\Request $request * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher @@ -54,6 +63,11 @@ abstract class BaseLoop $this->dispatcher = $dispatcher; } + public function getArgs() + { + return $this->defineArgs()->addArguments($this->getDefaultArgs()); + } + /** * * this function have to be implement in your own loop class. @@ -99,6 +113,6 @@ abstract class BaseLoop * * @return ArgumentCollection */ - abstract public function defineArgs(); + abstract protected function defineArgs(); } diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php index d2b6cdbb2..9fb72bff0 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/Argument.php @@ -22,6 +22,9 @@ /*************************************************************************************/ namespace Thelia\Core\Template\Loop\Argument; +use Thelia\Type\TypeCollection; +use Thelia\Type; + /** * * @author Etienne Roudeix @@ -42,4 +45,43 @@ class Argument $this->mandatory = $mandatory ? true : false; $this->default = $default; } + + public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true) + { + return new Argument( + $name, + new TypeCollection( + new Type\AnyType() + ), + $default, + $mandatory, + $empty + ); + } + + public static function createIntTypeArgument($name, $default=null, $mandatory=false, $empty=true) + { + return new Argument( + $name, + new TypeCollection( + new Type\IntType() + ), + $default, + $mandatory, + $empty + ); + } + + public static function createIntListTypeArgument($name, $default=null, $mandatory=false, $empty=true) + { + return new Argument( + $name, + new TypeCollection( + new Type\IntListType() + ), + $default, + $mandatory, + $empty + ); + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php b/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php index d3422c1e9..6aec1fd9b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php +++ b/core/lib/Thelia/Core/Template/Loop/Argument/ArgumentCollection.php @@ -35,9 +35,7 @@ class ArgumentCollection implements \Iterator public function __construct() { - foreach(func_get_args() as $argument) { - $this->addArgument($argument); - } + $this->addArguments(func_get_args()); } public function isEmpty() @@ -45,6 +43,20 @@ class ArgumentCollection implements \Iterator return count($this->arguments) == 0; } + /** + * @param array $argumentList + * + * @return ArgumentCollection + */ + public function addArguments(array $argumentList) + { + foreach($argumentList as $argument) { + $this->addArgument($argument); + } + + return $this; + } + /** * @param Argument $argument * diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index dadb69505..0af81e563 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -79,80 +79,23 @@ class Category extends BaseLoop { public $limit; public $offset; - public function defineArgs() + protected function defineArgs() { return new ArgumentCollection( - new Argument( - 'id', - new TypeCollection( - new Type\IntListType() - ) - ), - new Argument( - 'parent', - new TypeCollection( - new Type\IntType() - ) - ), - new Argument( - 'current', - new TypeCollection( - new Type\IntType() - ) - ), - new Argument( - 'not_empty', - new TypeCollection( - new Type\IntType() - ), - 0 - ), - new Argument( - 'visible', - new TypeCollection( - new Type\IntType() - ), - 1 - ), - new Argument( - 'link', - new TypeCollection( - new Type\AnyType() - ) - ), + Argument::createIntListTypeArgument('id'), + Argument::createIntTypeArgument('parent'), + Argument::createIntTypeArgument('current'), + Argument::createIntTypeArgument('not_empty', 0), + Argument::createIntTypeArgument('visible', 1), + Argument::createAnyTypeArgument('link'), new Argument( 'order', new TypeCollection( new Type\EnumType('alpha', 'alpha_reverse', 'reverse') ) ), - new Argument( - 'random', - new TypeCollection( - new Type\AnyType() - ), - 0 - ), - new Argument( - 'exclude', - new TypeCollection( - new Type\IntListType() - ) - ), - new Argument( - 'limit', - new TypeCollection( - new Type\IntType() - ), - 10 - ), - new Argument( - 'offset', - new TypeCollection( - new Type\IntType() - ), - 0 - ) + Argument::createIntTypeArgument('random', 0), + Argument::createIntListTypeArgument('exclude') ); } @@ -187,11 +130,11 @@ class Category extends BaseLoop { $search->filterByLink($this->link); } - if($this->limit > -1) { + /*if($this->limit > -1) { $search->limit($this->limit); - } + }*/ $search->filterByVisible($this->visible); - $search->offset($this->offset); + //$search->offset($this->offset); switch($this->order) { @@ -221,7 +164,8 @@ class Category extends BaseLoop { */ $search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN); - $categories = $search->find(); + //$categories = $search->find(); + $categories = $search->paginate($page = 2, $maxPerPage = 2); $loopResult = new LoopResult(); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index 67ccfcf98..a26471e4c 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -177,8 +177,8 @@ class TheliaLoop implements SmartyPluginInterface * * @param string $name * @return \Thelia\Core\Template\Element\BaseLoop - * @throws \Thelia\Tpex\Exception\InvalidElementException - * @throws \Thelia\Tpex\Exception\ElementNotFoundException + * @throws InvalidElementException + * @throws ElementNotFoundException */ protected function createLoopInstance($name) { @@ -204,8 +204,8 @@ class TheliaLoop implements SmartyPluginInterface /** * Returns the value of a loop argument. * - * @param unknown $loop a BaseLoop instance - * @param unknown $smartyParam + * @param BaseLoop $loop a BaseLoop instance + * @param $smartyParam * @throws \InvalidArgumentException */ protected function getLoopArgument(BaseLoop $loop, $smartyParam) @@ -218,7 +218,7 @@ class TheliaLoop implements SmartyPluginInterface $faultActor = array(); $faultDetails = array(); - $argumentsCollection = $loop->defineArgs(); + $argumentsCollection = $loop->getArgs(); foreach( $argumentsCollection as $argument ) { $value = isset($smartyParam[$argument->name]) ? $smartyParam[$argument->name] : null; @@ -275,7 +275,7 @@ class TheliaLoop implements SmartyPluginInterface * "myLoop" => "My\Own\Loop" * ); * - * @param array $loops + * @param array $loopDefinition * @throws \InvalidArgumentException if loop name already exists */ public function setLoopList(array $loopDefinition) diff --git a/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php similarity index 95% rename from core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php rename to core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php index 7c5ce5d16..b7556c10c 100755 --- a/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentTest.php +++ b/core/lib/Thelia/Tests/Core/Template/Loop/Argument/ArgumentCollectionTest.php @@ -113,17 +113,11 @@ class ArgumentTest extends \PHPUnit_Framework_TestCase $arguments = \PHPUnit_Framework_Assert::readAttribute($collection, 'arguments'); - $collection->rewind(); - while ($collection->valid()) { - - $argument = $collection->current(); - + foreach($collection as $key => $argument) { $this->assertEquals( $argument, - $arguments[$collection->key()] + $arguments[$key] ); - - $collection->next(); } } } diff --git a/core/lib/Thelia/Tests/Type/AnyTypeTest.php b/core/lib/Thelia/Tests/Type/AnyTypeTest.php new file mode 100755 index 000000000..8e959d154 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/AnyTypeTest.php @@ -0,0 +1,40 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\AnyType; + +/** + * + * @author Etienne Roudeix + * + */ +class AnyTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testAnyType() + { + $anyType = new AnyType(); + $this->assertTrue($anyType->isValid(md5(rand(1000, 10000)))); + } +} diff --git a/core/lib/Thelia/Tests/Type/EnumTypeTest.php b/core/lib/Thelia/Tests/Type/EnumTypeTest.php new file mode 100755 index 000000000..5ed4637e9 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/EnumTypeTest.php @@ -0,0 +1,43 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\EnumType; + +/** + * + * @author Etienne Roudeix + * + */ +class EnumTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testEnumType() + { + $enumType = new EnumType(array("cat", "dog")); + $this->assertTrue($enumType->isValid('cat')); + $this->assertTrue($enumType->isValid('dog')); + $this->assertFalse($enumType->isValid('monkey')); + $this->assertFalse($enumType->isValid('catdog')); + } +} diff --git a/core/lib/Thelia/Tests/Type/FloatTypeTest.php b/core/lib/Thelia/Tests/Type/FloatTypeTest.php new file mode 100755 index 000000000..82bf9bfe2 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/FloatTypeTest.php @@ -0,0 +1,42 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\FloatType; + +/** + * + * @author Etienne Roudeix + * + */ +class FloatTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testFloatType() + { + $floatType = new FloatType(); + $this->assertTrue($floatType->isValid('1.1')); + $this->assertTrue($floatType->isValid(2.2)); + $this->assertFalse($floatType->isValid('foo')); + } +} diff --git a/core/lib/Thelia/Tests/Type/IntListTypeTest.php b/core/lib/Thelia/Tests/Type/IntListTypeTest.php new file mode 100755 index 000000000..68b628a5c --- /dev/null +++ b/core/lib/Thelia/Tests/Type/IntListTypeTest.php @@ -0,0 +1,42 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\IntListType; + +/** + * + * @author Etienne Roudeix + * + */ +class IntListTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testIntListType() + { + $intListType = new IntListType(); + $this->assertTrue($intListType->isValid('1')); + $this->assertTrue($intListType->isValid('1,2,3')); + $this->assertFalse($intListType->isValid('1,2,3.3')); + } +} diff --git a/core/lib/Thelia/Tests/Type/IntTypeTest.php b/core/lib/Thelia/Tests/Type/IntTypeTest.php new file mode 100755 index 000000000..2f9ce8a40 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/IntTypeTest.php @@ -0,0 +1,42 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\IntType; + +/** + * + * @author Etienne Roudeix + * + */ +class IntTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testIntType() + { + $intType = new IntType(); + $this->assertTrue($intType->isValid('1')); + $this->assertTrue($intType->isValid(2)); + $this->assertFalse($intType->isValid('3.3')); + } +} diff --git a/core/lib/Thelia/Tests/Type/JsonTypeTest.php b/core/lib/Thelia/Tests/Type/JsonTypeTest.php new file mode 100755 index 000000000..276a867d2 --- /dev/null +++ b/core/lib/Thelia/Tests/Type/JsonTypeTest.php @@ -0,0 +1,41 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Tests\Type; + +use Thelia\Type\JsonType; + +/** + * + * @author Etienne Roudeix + * + */ +class JsonTypeTest extends \PHPUnit_Framework_TestCase +{ + public function testJsonType() + { + $jsonType = new JsonType(); + $this->assertTrue($jsonType->isValid('{"k0":"v0","k1":"v1","k2":"v2"}')); + $this->assertFalse($jsonType->isValid('1,2,3')); + } +} diff --git a/core/lib/Thelia/Tests/Type/TypeTest.php b/core/lib/Thelia/Tests/Type/TypeCollectionTest.php similarity index 62% rename from core/lib/Thelia/Tests/Type/TypeTest.php rename to core/lib/Thelia/Tests/Type/TypeCollectionTest.php index 4b7c65df8..5cef59215 100755 --- a/core/lib/Thelia/Tests/Type/TypeTest.php +++ b/core/lib/Thelia/Tests/Type/TypeCollectionTest.php @@ -37,18 +37,18 @@ class TypeTest extends \PHPUnit_Framework_TestCase { $collection = new TypeCollection( new Type\AnyType(), - new Type\AnyType() + new Type\IntType() ); $collection->addType( - new Type\AnyType() + new Type\FloatType() ); $this->assertAttributeEquals( array( new Type\AnyType(), - new Type\AnyType(), - new Type\AnyType(), + new Type\IntType(), + new Type\FloatType(), ), 'types', $collection @@ -59,55 +59,18 @@ class TypeTest extends \PHPUnit_Framework_TestCase { $collection = new TypeCollection( new Type\AnyType(), - new Type\AnyType(), - new Type\AnyType() + new Type\IntType(), + new Type\FloatType() ); $types = \PHPUnit_Framework_Assert::readAttribute($collection, 'types'); - $collection->rewind(); - while ($collection->valid()) { - - $type = $collection->current(); - + foreach($collection as $key => $type) { $this->assertEquals( $type, - $types[$collection->key()] + $types[$key] ); - - $collection->next(); } } - - public function testTypes() - { - $anyType = new Type\AnyType(); - $this->assertTrue($anyType->isValid(md5(rand(1000, 10000)))); - - $intType = new Type\IntType(); - $this->assertTrue($intType->isValid('1')); - $this->assertTrue($intType->isValid(2)); - $this->assertFalse($intType->isValid('3.3')); - - $floatType = new Type\FloatType(); - $this->assertTrue($floatType->isValid('1.1')); - $this->assertTrue($floatType->isValid(2.2)); - $this->assertFalse($floatType->isValid('foo')); - - $enumType = new Type\EnumType(array("cat", "dog")); - $this->assertTrue($enumType->isValid('cat')); - $this->assertTrue($enumType->isValid('dog')); - $this->assertFalse($enumType->isValid('monkey')); - $this->assertFalse($enumType->isValid('catdog')); - - $intListType = new Type\IntListType(); - $this->assertTrue($intListType->isValid('1')); - $this->assertTrue($intListType->isValid('1,2,3')); - $this->assertFalse($intListType->isValid('1,2,3.3')); - - $jsonType = new Type\JsonType(); - $this->assertTrue($jsonType->isValid('{"k0":"v0","k1":"v1","k2":"v2"}')); - $this->assertFalse($jsonType->isValid('1,2,3')); - } } From 3aca4bfb2528267552214fb8207545d4ae1988a8 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 26 Jun 2013 16:09:46 +0200 Subject: [PATCH 03/35] pagination --- .../Thelia/Core/Template/Element/BaseLoop.php | 33 +++++++++++++++++-- .../Thelia/Core/Template/Loop/Category.php | 11 +------ templates/smarty-sample/index.html | 16 +++++++++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 821055204..adc406d7a 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -45,11 +45,16 @@ abstract class BaseLoop */ public $dispatcher; + public $limit; + public $page; + public $offset; + protected function getDefaultArgs() { return array( - Argument::createIntTypeArgument('offset'), - Argument::createIntTypeArgument('limit'), + Argument::createIntTypeArgument('offset', 0), + Argument::createIntTypeArgument('page'), + Argument::createIntTypeArgument('limit', 10), ); } @@ -68,6 +73,30 @@ abstract class BaseLoop return $this->defineArgs()->addArguments($this->getDefaultArgs()); } + public function search(\ModelCriteria $search) + { + if($this->page !== null) { + return $this->searchWithPagination($search); + } else { + return $this->searchWithOffset($search); + } + } + + public function searchWithOffset(\ModelCriteria $search) + { + if($this->limit >= 0) { + $search->limit($this->limit); + } + $search->offset($this->offset); + + return $search->find(); + } + + public function searchWithPagination(\ModelCriteria $search) + { + return $search->paginate($this->page, $this->limit); + } + /** * * this function have to be implement in your own loop class. diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 0af81e563..2a47ac835 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -51,8 +51,6 @@ use Thelia\Type; * * by default results are sorting by position ascending * - random : if 1, random results. Default value is 0 * - exclude : all category id you want to exclude (as for id, an integer or a "string list" can be used) - * - limit : number of results. Default value is 10 - * - offset : at witch id start the search * * example : * @@ -76,8 +74,6 @@ class Category extends BaseLoop { public $order; public $random; public $exclude; - public $limit; - public $offset; protected function defineArgs() { @@ -130,11 +126,7 @@ class Category extends BaseLoop { $search->filterByLink($this->link); } - /*if($this->limit > -1) { - $search->limit($this->limit); - }*/ $search->filterByVisible($this->visible); - //$search->offset($this->offset); switch($this->order) { @@ -164,8 +156,7 @@ class Category extends BaseLoop { */ $search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN); - //$categories = $search->find(); - $categories = $search->paginate($page = 2, $maxPerPage = 2); + $categories = $this->search($search); $loopResult = new LoopResult(); diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 9135b8867..c9d4e6842 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -84,4 +84,20 @@ An image from asset directory : {/loop} +
+

Some pagination

+

PAGE 1

+
    + {loop type="category" name="catloopwithpagination" limit="2" page="1"} +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • + {/loop} +
+

PAGE 2

+
    + {loop type="category" name="catloopwithpagination" limit="2" page="2"} +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • + {/loop} +
+
+ {include file="includes/footer.html"} \ No newline at end of file From 3fb5466ef311e7988053a020ffc1034a699e1154 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 27 Jun 2013 13:18:29 +0200 Subject: [PATCH 04/35] pagination --- .../Thelia/Core/Template/Element/BaseLoop.php | 23 +++-- .../Thelia/Core/Template/Loop/Category.php | 4 +- .../Template/Smarty/Plugins/TheliaLoop.php | 83 ++++++++++++++++--- templates/smarty-sample/index.html | 45 +++++++++- 4 files changed, 134 insertions(+), 21 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index adc406d7a..1293d96a6 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Template\Element; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; /** @@ -73,10 +72,10 @@ abstract class BaseLoop return $this->defineArgs()->addArguments($this->getDefaultArgs()); } - public function search(\ModelCriteria $search) + public function search(\ModelCriteria $search, &$pagination = null) { if($this->page !== null) { - return $this->searchWithPagination($search); + return $this->searchWithPagination($search, $pagination); } else { return $this->searchWithOffset($search); } @@ -92,9 +91,19 @@ abstract class BaseLoop return $search->find(); } - public function searchWithPagination(\ModelCriteria $search) + public function searchWithPagination(\ModelCriteria $search, &$pagination) { - return $search->paginate($this->page, $this->limit); + $pagination = $search->paginate($this->page, $this->limit); + + //$toto = $pagination->haveToPaginate(); + //$toto = $pagination->getNbResults(); + //$toto2 = $pagination->count(); + + if($this->page > $pagination->getLastPage()) { + return array(); + } else { + return $pagination; + } } /** @@ -121,7 +130,7 @@ abstract class BaseLoop * * @return mixed */ - abstract public function exec(); + abstract public function exec(&$pagination); /** * @@ -140,7 +149,7 @@ abstract class BaseLoop * ) * ); * - * @return ArgumentCollection + * @return \Thelia\Core\Template\Element\LoopResult */ abstract protected function defineArgs(); diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 2a47ac835..f229d9340 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -100,7 +100,7 @@ class Category extends BaseLoop { * * @return \Thelia\Core\Template\Element\LoopResult */ - public function exec() + public function exec(&$pagination) { $search = CategoryQuery::create(); @@ -156,7 +156,7 @@ class Category extends BaseLoop { */ $search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN); - $categories = $this->search($search); + $categories = $this->search($search, $pagination); $loopResult = new LoopResult(); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index a26471e4c..a7947215f 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -35,6 +35,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; class TheliaLoop implements SmartyPluginInterface { + protected static $pagination = null; protected $loopDefinition = array(); @@ -48,6 +49,20 @@ class TheliaLoop implements SmartyPluginInterface $this->dispatcher = $dispatcher; } + /** + * @param $loopId + * + * @return \PropelModelPager + */ + public static function getPagination($loopId) + { + if(!empty(self::$pagination[$loopId])) { + return self::$pagination[$loopId]; + } else { + return null; + } + } + /** * Process {loop name="loop name" type="loop type" ... } ... {/loop} block * @@ -75,11 +90,13 @@ class TheliaLoop implements SmartyPluginInterface $this->getLoopArgument($loop, $params); - $loopResults = $loop->exec(); + self::$pagination[$name] = null; + + $loopResults = $loop->exec(self::$pagination[$name]); $template->assignByRef($name, $loopResults); - } - else { + + } else { $loopResults = $template->getTemplateVars($name); @@ -97,7 +114,8 @@ class TheliaLoop implements SmartyPluginInterface $template->assign('__COUNT__', 1 + $loopResults->key()); $template->assign('__TOTAL__', $loopResults->getCount()); - $repeat = $loopResults->valid(); + //$repeat = $loopResults->valid(); + $repeat = true; } if ($content !== null) { @@ -139,13 +157,62 @@ class TheliaLoop implements SmartyPluginInterface */ public function theliaIfLoop($params, $content, $template, &$repeat) { - // When encountering close tag, check if loop has results. if ($repeat === false) { return $this->checkEmptyLoop($params, $template) ? '' : $content; } } + /** + * Process {pageloop rel="loopname"} ... {/pageloop} block + * + * @param $params + * @param $content + * @param $template + * @param $repeat + * + * @return string + * @throws \InvalidArgumentException + */ + public function theliaPageLoop($params, $content, $template, &$repeat) + { + if (empty($params['rel'])) + throw new \InvalidArgumentException("Missing 'rel' parameter in page loop"); + + $loopName = $params['rel']; + + // Find loop results in the current template vars + $loopResults = $template->getTemplateVars($loopName); + if (empty($loopResults)) { + throw new \InvalidArgumentException("Loop $loopName is not defined."); + } + + // Find pagination + $pagination = self::getPagination($loopName); + if ($pagination === null) { + throw new \InvalidArgumentException("Loop $loopName : no pagination found."); + } + + if ($content === null) { + $page = 1; + } else { + $page = $template->getTemplateVars('PAGE'); + $page++; + } + + if ($page <= $pagination->getLastPage()) { + $template->assign('PAGE', $page); + $template->assign('CURRENT', $pagination->getPage()); + $template->assign('LAST', $pagination->getLastPage()); + + $repeat = true; + } + + if ($content !== null) { + return $content; + } + } + /** * Check if a loop has returned results. The loop shoud have been executed before, or an * InvalidArgumentException is thrown @@ -210,11 +277,6 @@ class TheliaLoop implements SmartyPluginInterface */ protected function getLoopArgument(BaseLoop $loop, $smartyParam) { - $defaultItemsParams = array('required' => true); - - $shortcutItemParams = array('optional' => array('required' => false)); - - $errorCode = 0; $faultActor = array(); $faultDetails = array(); @@ -300,6 +362,7 @@ class TheliaLoop implements SmartyPluginInterface new SmartyPluginDescriptor('block', 'loop' , $this, 'theliaLoop'), new SmartyPluginDescriptor('block', 'elseloop' , $this, 'theliaElseloop'), new SmartyPluginDescriptor('block', 'ifloop' , $this, 'theliaIfLoop'), + new SmartyPluginDescriptor('block', 'pageloop' , $this, 'theliaPageLoop'), ); } } \ No newline at end of file diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index c9d4e6842..aea81cd3d 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -88,16 +88,57 @@ An image from asset directory :

Some pagination

PAGE 1

    - {loop type="category" name="catloopwithpagination" limit="2" page="1"} + {loop type="category" name="catloopwithpagination1" limit="2" page="1"}
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • {/loop}

PAGE 2

    - {loop type="category" name="catloopwithpagination" limit="2" page="2"} + {loop type="category" name="catloopwithpagination2" limit="2" page="2"}
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • {/loop}
+

PAGE 1000

+
    + + {loop type="category" name="catloopwithpagination1000" limit="2" page="1000"} +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • + {/loop} + + {elseloop rel="catloopwithpagination1000"} + NO RESULTS + {/elseloop} +
+ + +
+

Some pagination with page choice

+ {assign var=current_page value=2} +

PAGE {$current_page} :

+
    + {loop type="category" name="catloopwithpaginationchoice" limit="2" page="{$current_page}"} +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • + {/loop} +
+

page choice

+ {pageloop rel="catloopwithpaginationchoice"} + {if ${PAGE} != {$current_page}} + {if {$PAGE} > {$current_page}-10 AND {$PAGE} < {$current_page}+10} + {$PAGE} + {/if} + {if {$PAGE} == {$current_page}-10 OR {$PAGE} == {$current_page}+10} + ... + {/if} + {if ({$PAGE} < {$current_page}-10 OR {$PAGE} > {$current_page}+10) AND ({$PAGE}%10 == 0 OR ${PAGE} == {$LAST} OR ${PAGE} == 1)} + {$PAGE} + {/if} + {else} + { {$PAGE} } + {/if} + {if {$PAGE} != {$LAST}} + - + {/if} + {/pageloop}
{include file="includes/footer.html"} \ No newline at end of file From fc4a0734dbaadb5231537e706ec2b6cc80653c14 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Thu, 27 Jun 2013 16:08:36 +0200 Subject: [PATCH 05/35] no more test loops --- .../Thelia/Core/Template/TestLoop/Equal.php | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100755 core/lib/Thelia/Core/Template/TestLoop/Equal.php diff --git a/core/lib/Thelia/Core/Template/TestLoop/Equal.php b/core/lib/Thelia/Core/Template/TestLoop/Equal.php deleted file mode 100755 index 5e812a7a4..000000000 --- a/core/lib/Thelia/Core/Template/TestLoop/Equal.php +++ /dev/null @@ -1,51 +0,0 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Core\Template\TestLoop; - -use Thelia\Tpex\Element\TestLoop\BaseTestLoop; - -/** - * - * TestLoop equal, test if value and variable are equal - * - * example : - * - * - * Result display here if variable and value are equal - * - * Result display here if variable and value are not equal - * - * - * Class Equal - * @package Thelia\Core\Template\TestLoop - * @author Manuel Raynaud - */ -class Equal extends BaseTestLoop -{ - - public function exec($variable, $value) - { - return $variable == $value; - } -} \ No newline at end of file From 3b5b29c6e0db27b9d0d5d95892807cdafae2c8d3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 11:10:52 +0200 Subject: [PATCH 06/35] retrieve form error in front office --- core/lib/Thelia/Action/Customer.php | 2 +- .../Admin/Controller/BaseAdminController.php | 12 ------------ core/lib/Thelia/Core/Event/ActionEvent.php | 19 +++++++++++++++++++ .../Core/EventListener/ControllerListener.php | 9 ++++++++- .../Core/Template/Smarty/Plugins/Form.php | 13 +++++++++++-- core/lib/Thelia/Form/BaseForm.php | 13 +++++++++++-- core/lib/Thelia/Form/CustomerCreation.php | 5 +++++ templates/smarty-sample/index.html | 3 +++ 8 files changed, 58 insertions(+), 18 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 186b8e34c..a794035e2 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -46,7 +46,7 @@ class Customer implements EventSubscriberInterface if ($form->isValid()) { echo "ok"; exit; } else { - echo "ko"; exit; + $event->setFormError($form); } } } diff --git a/core/lib/Thelia/Admin/Controller/BaseAdminController.php b/core/lib/Thelia/Admin/Controller/BaseAdminController.php index 3aa0e9281..1c193a966 100755 --- a/core/lib/Thelia/Admin/Controller/BaseAdminController.php +++ b/core/lib/Thelia/Admin/Controller/BaseAdminController.php @@ -79,16 +79,4 @@ class BaseAdminController extends ContainerAware return $parser; } - - public function getFormFactory() - { - return BaseForm::getFormFactory($this->getRequest(), ConfigQuery::read("form.secret.admin", md5(__DIR__))); - } - - public function getFormBuilder() - { - return $this->getFormFactory()->createBuilder("form"); - } - - } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/ActionEvent.php b/core/lib/Thelia/Core/Event/ActionEvent.php index b2d1d7b77..32074c559 100755 --- a/core/lib/Thelia/Core/Event/ActionEvent.php +++ b/core/lib/Thelia/Core/Event/ActionEvent.php @@ -47,6 +47,8 @@ abstract class ActionEvent extends Event */ protected $action; + protected $form; + /** * * @param \Symfony\Component\HttpFoundation\Request $request @@ -75,4 +77,21 @@ abstract class ActionEvent extends Event { return $this->request; } + + public function setFormError($form) + { + $this->form = $form; + $this->stopPropagation(); + } + + public function getForm() + { + return $this->form; + } + + public function hasFormError() + { + return $this->form !== null; + } + } diff --git a/core/lib/Thelia/Core/EventListener/ControllerListener.php b/core/lib/Thelia/Core/EventListener/ControllerListener.php index 607c2a44d..93c827c09 100755 --- a/core/lib/Thelia/Core/EventListener/ControllerListener.php +++ b/core/lib/Thelia/Core/EventListener/ControllerListener.php @@ -46,7 +46,14 @@ class ControllerListener implements EventSubscriberInterface if (false !== $action = $request->get("action")) { //search corresponding action $event = new ActionEventFactory($request, $action, $event->getKernel()->getContainer()->getParameter("thelia.actionEvent")); - $dispatcher->dispatch("action.".$action, $event->createActionEvent()); + $actionEvent = $event->createActionEvent(); + $dispatcher->dispatch("action.".$action, $actionEvent); + + if ($actionEvent->hasFormError()) { + $request->getSession()->set("form_error", true); + $request->getSession()->set("form_name", $actionEvent->getForm()->createView() + ->vars["attr"]["thelia_name"]); + } } } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 51ff06e9c..0870ba2c2 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -88,8 +88,14 @@ class Form implements SmartyPluginInterface } $instance = $this->getInstance($params['name']); + $form = $instance->getForm(); - $template->assign("form", $instance->getForm()->createView()); + if (true === $this->request->getSession()->get("form_error", false) && $this->request->getSession()->get + ("form_name") == $instance->getName()) { + $form->bind($this->request); + } + + $template->assign("form", $form->createView()); } else { return $content; } @@ -202,7 +208,10 @@ class Form implements SmartyPluginInterface $class = new \ReflectionClass($this->formDefinition[$name]); - return $class->newInstance($this->request); + return $class->newInstance( + $this->request, + "form" + ); } /** diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 02f86fe02..cbcebf173 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -30,6 +30,7 @@ use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; use Symfony\Component\Validator\Validation; +use Thelia\Form\Extension\NameFormExtension; use Thelia\Model\ConfigQuery; abstract class BaseForm { @@ -38,17 +39,23 @@ abstract class BaseForm { */ protected $form; + public $name; + public function __construct(Request $request, $type= "form", $data = array(), $options = array()) { $validator = Validation::createValidator(); + if(!isset($options["attr"]["name"])) { + $options["attr"]["thelia_name"] = $this->getName(); + } + $this->form = Forms::createFormFactoryBuilder() ->addExtension(new HttpFoundationExtension()) ->addExtension( new CsrfExtension( new SessionCsrfProvider( $request->getSession(), - isset($option["secret"]) ? $option["secret"] : ConfigQuery::read("form.secret", md5(__DIR__)) + isset($options["secret"]) ? $options["secret"] : ConfigQuery::read("form.secret", md5(__DIR__)) ) ) ) @@ -57,6 +64,8 @@ abstract class BaseForm { ->createBuilder($type, $data, $options); ; + + $this->buildForm(); } @@ -69,6 +78,6 @@ abstract class BaseForm { } abstract protected function buildForm(); - + abstract public function getName(); } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 68726356d..bcfacbf8a 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -45,4 +45,9 @@ class CustomerCreation extends BaseForm ) ->add('age', 'integer'); } + + public function getName() + { + return "customerCreation"; + } } \ No newline at end of file diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 174505335..25814172e 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -12,6 +12,9 @@ An image from asset directory : {form_field_hidden form=$form} {form_field form=$form.email} + {form_error form=$form.email} + {$message} + {/form_error} {intl l="{$label}"} : {/form_field} From 8ba9a4beef16e769fbe212351b0cab4cb5d801e1 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 1 Jul 2013 11:19:32 +0200 Subject: [PATCH 07/35] phpdoc update --- .../Thelia/Core/Template/Element/BaseLoop.php | 28 ++++++++++++++----- .../Thelia/Core/Template/Loop/Category.php | 5 +++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 1293d96a6..6863f1a09 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -72,6 +72,12 @@ abstract class BaseLoop return $this->defineArgs()->addArguments($this->getDefaultArgs()); } + /** + * @param \ModelCriteria $search + * @param null $pagination + * + * @return array|mixed|\PropelModelPager|\PropelObjectCollection + */ public function search(\ModelCriteria $search, &$pagination = null) { if($this->page !== null) { @@ -81,6 +87,11 @@ abstract class BaseLoop } } + /** + * @param \ModelCriteria $search + * + * @return array|mixed|\PropelObjectCollection + */ public function searchWithOffset(\ModelCriteria $search) { if($this->limit >= 0) { @@ -91,14 +102,16 @@ abstract class BaseLoop return $search->find(); } + /** + * @param \ModelCriteria $search + * @param $pagination + * + * @return array|\PropelModelPager + */ public function searchWithPagination(\ModelCriteria $search, &$pagination) { $pagination = $search->paginate($this->page, $this->limit); - //$toto = $pagination->haveToPaginate(); - //$toto = $pagination->getNbResults(); - //$toto2 = $pagination->count(); - if($this->page > $pagination->getLastPage()) { return array(); } else { @@ -128,9 +141,10 @@ abstract class BaseLoop * * you can retrieve ref value using $this->ref * + * @param $pagination + * * @return mixed - */ - abstract public function exec(&$pagination); + */abstract public function exec(&$pagination); /** * @@ -149,7 +163,7 @@ abstract class BaseLoop * ) * ); * - * @return \Thelia\Core\Template\Element\LoopResult + * @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection */ abstract protected function defineArgs(); diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index e372b2f18..55be4d69a 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -75,6 +75,9 @@ class Category extends BaseLoop public $random; public $exclude; + /** + * @return ArgumentCollection + */ protected function defineArgs() { return new ArgumentCollection( @@ -96,7 +99,7 @@ class Category extends BaseLoop } /** - * + * @param $pagination * * @return \Thelia\Core\Template\Element\LoopResult */ From 0dc10d509744c624eb79377dc37994c81fa10ed1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 11:20:40 +0200 Subject: [PATCH 08/35] add some phpdoc for form creation explanation --- core/lib/Thelia/Form/BaseForm.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index cbcebf173..3c76df1b5 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -77,7 +77,31 @@ abstract class BaseForm { return $this->form->getForm(); } + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->form attribute : + * + * $this->form->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ abstract protected function buildForm(); + + /** + * @return string the name of you form. This name must be unique + */ abstract public function getName(); } From 26be670f5724494bd064605ee5771a22a6e1b813 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 11:22:05 +0200 Subject: [PATCH 09/35] reset form session after binding errors --- core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 0870ba2c2..f7ee96d2a 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -93,6 +93,7 @@ class Form implements SmartyPluginInterface if (true === $this->request->getSession()->get("form_error", false) && $this->request->getSession()->get ("form_name") == $instance->getName()) { $form->bind($this->request); + $this->request->getSession()->set("form_error", false); } $template->assign("form", $form->createView()); From 762b5bc71c3aded1bc7ad0f74f26f618fb06f477 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 11:54:40 +0200 Subject: [PATCH 10/35] name all form field --- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Core/Template/Smarty/Plugins/Form.php | 6 ++++-- core/lib/Thelia/Form/AdminLogin.php | 5 +++++ core/lib/Thelia/Form/BaseForm.php | 2 +- templates/smarty-sample/index.html | 15 +++++++++++++++ 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index d1e6569fa..4eb0217ae 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -23,6 +23,7 @@
+ diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index f7ee96d2a..2ff6be8e3 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -90,8 +90,10 @@ class Form implements SmartyPluginInterface $instance = $this->getInstance($params['name']); $form = $instance->getForm(); - if (true === $this->request->getSession()->get("form_error", false) && $this->request->getSession()->get - ("form_name") == $instance->getName()) { + if ( + true === $this->request->getSession()->get("form_error", false) && + $this->request->getSession()->get("form_name") == $instance->getName()) + { $form->bind($this->request); $this->request->getSession()->set("form_error", false); } diff --git a/core/lib/Thelia/Form/AdminLogin.php b/core/lib/Thelia/Form/AdminLogin.php index 2fa2c8d5f..33810f771 100644 --- a/core/lib/Thelia/Form/AdminLogin.php +++ b/core/lib/Thelia/Form/AdminLogin.php @@ -41,4 +41,9 @@ class AdminLogin extends BaseForm { ->add("password", "password"); } + public function getName() + { + return "admin_login"; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 3c76df1b5..3a6d69cb3 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -61,7 +61,7 @@ abstract class BaseForm { ) ->addExtension(new ValidatorExtension($validator)) ->getFormFactory() - ->createBuilder($type, $data, $options); + ->createNamedBuilder($this->getName(), $type, $data, $options); ; diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 25814172e..28f78f06c 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -27,6 +27,21 @@ An image from asset directory :
{/form} + +
+ +{form name="thelia.admin_login"} +
+ {form_field_hidden form=$form} + {form_field form=$form.username} + username : + {/form_field} + + {form_field form=$form.password} + password : + {/form_field} +
+{/form}
jQuery data:
From 6e292944180274b02d5b33502a5665adc423ff5e Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 15:39:58 +0200 Subject: [PATCH 11/35] update create customer form --- core/lib/Thelia/Action/Customer.php | 6 +++ core/lib/Thelia/Core/Event/TheliaEvents.php | 4 ++ core/lib/Thelia/Form/CustomerCreation.php | 54 ++++++++++++++++----- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index a794035e2..7a26d40b6 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -25,6 +25,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Form\BaseForm; use Thelia\Form\CustomerCreation; @@ -33,6 +34,9 @@ class Customer implements EventSubscriberInterface public function create(ActionEvent $event) { + + $event->getDispatcher()->dispatch(TheliaEvents::BEFORE_CREATECUSTOMER, $event); + $request = $event->getRequest(); $customerForm = new CustomerCreation($request); @@ -49,6 +53,8 @@ class Customer implements EventSubscriberInterface $event->setFormError($form); } } + + $event->getDispatcher()->dispatch(TheliaEvents::AFTER_CREATECUSTOMER, $event); } public function modify(ActionEvent $event) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 3ffac068f..8f44d7fb5 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -47,4 +47,8 @@ final class TheliaEvents * Send before starting thelia inclusion */ const INCLUSION = "thelia.include"; + + const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; + + const AFTER_CREATECUSTOMER = "action.after_createcustomer"; } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index bcfacbf8a..a925d3d56 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -24,7 +24,8 @@ namespace Thelia\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints; +use Thelia\Model\ConfigQuery; class CustomerCreation extends BaseForm @@ -32,18 +33,47 @@ class CustomerCreation extends BaseForm protected function buildForm() { - $this->form->add("name", "text") - ->add("email", "email", array( - "attr" => array( - "class" => "field" - ), - "label" => "email", - "constraints" => array( - new NotBlank() - ) + $this->form + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() ) - ) - ->add('age', 'integer'); + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("email", "email", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Email() + ) + )) + ->add("address1", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("address2", "text") + ->add("address3", "text") + ->add("zipcode", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("country", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ) + )) + ->add("password", "password", array( + "constraints" => array( + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) + ) + )) + + ; } public function getName() From 62a3dc3074560f18ee358a9cd57dfc3c7030159f Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 16:16:24 +0200 Subject: [PATCH 12/35] create creation account form --- core/lib/Thelia/Form/CustomerCreation.php | 20 +++++++++----- templates/smarty-sample/connexion.html | 27 +++++++++++++++++++ templates/smarty-sample/index.html | 33 ----------------------- 3 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 templates/smarty-sample/connexion.html diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index a925d3d56..80efb74da 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -37,26 +37,34 @@ class CustomerCreation extends BaseForm ->add("firstname", "text", array( "constraints" => array( new Constraints\NotBlank() - ) + ), + "label" => "firstname" )) ->add("lastname", "text", array( "constraints" => array( new Constraints\NotBlank() - ) + ), + "label" => "lastname" )) ->add("email", "email", array( "constraints" => array( new Constraints\NotBlank(), new Constraints\Email() - ) + ), + "label" => "email" )) ->add("address1", "text", array( "constraints" => array( new Constraints\NotBlank() - ) + ), + "label" => "address" + )) + ->add("address2", "text", array( + "label" => "Address Line 2" + )) + ->add("address3", "text", array( + "label" => "Address Line 3" )) - ->add("address2", "text") - ->add("address3", "text") ->add("zipcode", "text", array( "constraints" => array( new Constraints\NotBlank() diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html new file mode 100644 index 000000000..69c4b516c --- /dev/null +++ b/templates/smarty-sample/connexion.html @@ -0,0 +1,27 @@ +{include file="includes/header.html"} + +{form name="thelia.customer.creation"} +
+ + {form_field_hidden form=$form} + {form_field form=$form.firstname} + {form_error form=$form.firstname} + {$message} + {/form_error} + + + {/form_field} + + {form_field form=$form.lastname} + {form_error form=$form.lastname} + {$message} + {/form_error} + + + {/form_field} + + +
+{/form} + +{include file="includes/footer.html"} \ No newline at end of file diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 28f78f06c..e04fbf097 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -7,41 +7,8 @@ An image from asset directory :
{intl l='An internationalized string'}
-{form name="thelia.customer.creation"} -
- {form_field_hidden form=$form} - {form_field form=$form.email} - {form_error form=$form.email} - {$message} - {/form_error} - {intl l="{$label}"} : - {/form_field} - {form_field form=$form.name} - {intl l='name'} : - {/form_field} - {form_field form=$form.age} - {intl l='age'} : - {/form_field} - -
-{/form} - -
- -{form name="thelia.admin_login"} -
- {form_field_hidden form=$form} - {form_field form=$form.username} - username : - {/form_field} - - {form_field form=$form.password} - password : - {/form_field} -
-{/form}
jQuery data:
From b820afa9456efb9f408d5c7ce627edbc47ab8979 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 1 Jul 2013 16:27:43 +0200 Subject: [PATCH 13/35] continue to implement form customer --- core/lib/Thelia/Form/CustomerCreation.php | 6 ++- templates/smarty-sample/connexion.html | 50 ++++++++++++++++++++++- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 80efb74da..a8490fc43 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -68,12 +68,14 @@ class CustomerCreation extends BaseForm ->add("zipcode", "text", array( "constraints" => array( new Constraints\NotBlank() - ) + ), + "label" => "zipcode" )) ->add("country", "text", array( "constraints" => array( new Constraints\NotBlank() - ) + ), + "label" => "country" )) ->add("password", "password", array( "constraints" => array( diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index 69c4b516c..d16aa52e9 100644 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -9,7 +9,7 @@ {$message} {/form_error} - +
{/form_field} {form_field form=$form.lastname} @@ -17,7 +17,53 @@ {$message} {/form_error} - +
+ {/form_field} + + {form_field form=$form.address1} + {form_error form=$form.address1} + {$message} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.address2} + {form_error form=$form.address2} + {$message} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.address3} + {form_error form=$form.address3} + {$message} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.zipcode} + {form_error form=$form.zipcode} + {$message} + {/form_error} + +
+ {/form_field} + + {form_field form=$form.country} + {form_error form=$form.country} + {$message} + {/form_error} + + + +
{/form_field} From e15c53625ea04717ad0d07b9a9263d249199f20c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 11:48:34 +0200 Subject: [PATCH 14/35] complete CustomerCreation form --- core/lib/Thelia/Action/Customer.php | 1 + core/lib/Thelia/Form/CustomerCreation.php | 71 ++++++++++++++++++++--- core/lib/Thelia/Model/Customer.php | 1 + core/lib/Thelia/Model/CustomerQuery.php | 1 + templates/smarty-sample/connexion.html | 30 +++++++++- 5 files changed, 95 insertions(+), 9 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 7a26d40b6..bc1a3567c 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -50,6 +50,7 @@ class Customer implements EventSubscriberInterface if ($form->isValid()) { echo "ok"; exit; } else { + $event->setFormError($form); } } diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index a8490fc43..f03c99cc8 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -25,7 +25,10 @@ namespace Thelia\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContext; +use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Model\ConfigQuery; +use Thelia\Model\CustomerQuery; class CustomerCreation extends BaseForm @@ -46,13 +49,6 @@ class CustomerCreation extends BaseForm ), "label" => "lastname" )) - ->add("email", "email", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Email() - ), - "label" => "email" - )) ->add("address1", "text", array( "constraints" => array( new Constraints\NotBlank() @@ -77,15 +73,74 @@ class CustomerCreation extends BaseForm ), "label" => "country" )) + ->add("email", "email", array( + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Email(), + new Constraints\Callback(array( + "methods" => array( + $this, + "verifyExistingEmail" + ) + )) + ), + "label" => "email" + )) + ->add("email_confirm", "email", array( + "constraints" => array( + new Constraints\Callback(array( + "methods" => array( + $this, + "verifyEmailField" + ) + )) + ), + "label" => "email confirmation" + )) ->add("password", "password", array( "constraints" => array( new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) - ) + ), + "label" => "password" + )) + ->add("password_confirm", "password", array( + "constraints" => array( + new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), + new Constraints\Callback(array("methods" => array( + array($this, "verifyPasswordField") + ))) + ), + "label" => "password confirmation" )) ; } + public function verifyPasswordField($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + if ($data["password"] != $data["password_confirm"]) { + $context->addViolation("password confirmation is not the same as password field"); + } + } + + public function verifyEmailField($value, ExecutionContextInterface $context) + { + $data = $context->getRoot()->getData(); + + if ($data["email"] != $data["email_confirm"]) { + $context->addViolation("email confirmation is not the same as email field"); + } + } + + public function verifyExistingEmail($value, ExecutionContextInterface $context) + { + if (CustomerQuery::create()->filterByEmail($value)->exists()) { + $context->addViolation("This email already exists"); + } + } + public function getName() { return "customerCreation"; diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 835f91e59..9e9018620 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -18,4 +18,5 @@ use Thelia\Model\om\BaseCustomer; */ class Customer extends BaseCustomer { + } diff --git a/core/lib/Thelia/Model/CustomerQuery.php b/core/lib/Thelia/Model/CustomerQuery.php index 0a9c9bcf2..ac97850bf 100755 --- a/core/lib/Thelia/Model/CustomerQuery.php +++ b/core/lib/Thelia/Model/CustomerQuery.php @@ -18,4 +18,5 @@ use Thelia\Model\om\BaseCustomerQuery; */ class CustomerQuery extends BaseCustomerQuery { + } diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index d16aa52e9..b3137152a 100644 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -1,7 +1,7 @@ {include file="includes/header.html"} {form name="thelia.customer.creation"} -
+ {form_field_hidden form=$form} {form_field form=$form.firstname} @@ -66,6 +66,34 @@
{/form_field} + {form_field form=$form.email} + {form_error form=$form.email} + {#message} + {/form_error} +
+ {/form_field} + + {form_field form=$form.email_confirm} + {form_error form=$form.email_confirm} + {#message} + {/form_error} +
+ {/form_field} + + {form_field form=$form.password} + {form_error form=$form.password} + {#message} + {/form_error} +
+ {/form_field} + + {form_field form=$form.password_confirm} + {form_error form=$form.password_confirm} + {#message} + {/form_error} +
+ {/form_field} +
{/form} From 33aba6b3d5563635599be31b1cc0ddcf2ce98abf Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 14:35:18 +0200 Subject: [PATCH 15/35] add missing field to customerCreation field --- core/lib/Thelia/Action/Customer.php | 1 + core/lib/Thelia/Form/CustomerCreation.php | 20 ++++++++++--- core/lib/Thelia/Model/Customer.php | 25 ++++++++++++++++ templates/smarty-sample/connexion.html | 36 ++++++++++++++++++----- 4 files changed, 71 insertions(+), 11 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index bc1a3567c..ca0ce3652 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -48,6 +48,7 @@ class Customer implements EventSubscriberInterface $form->bind($request); if ($form->isValid()) { + echo "ok"; exit; } else { diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index f03c99cc8..4edd5628e 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -61,12 +61,24 @@ class CustomerCreation extends BaseForm ->add("address3", "text", array( "label" => "Address Line 3" )) + ->add("phone", "text", array( + "label" => "phone" + )) + ->add("cellphone", "text", array( + "label" => "cellphone" + )) ->add("zipcode", "text", array( "constraints" => array( new Constraints\NotBlank() ), "label" => "zipcode" )) + ->add("city", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "city" + )) ->add("country", "text", array( "constraints" => array( new Constraints\NotBlank() @@ -79,8 +91,8 @@ class CustomerCreation extends BaseForm new Constraints\Email(), new Constraints\Callback(array( "methods" => array( - $this, - "verifyExistingEmail" + array($this, + "verifyExistingEmail") ) )) ), @@ -90,8 +102,8 @@ class CustomerCreation extends BaseForm "constraints" => array( new Constraints\Callback(array( "methods" => array( - $this, - "verifyEmailField" + array($this, + "verifyEmailField") ) )) ), diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 9e9018620..885d867b0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -18,5 +18,30 @@ use Thelia\Model\om\BaseCustomer; */ class Customer extends BaseCustomer { + public function create($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) + { + $this + ->setFirstname($firstname) + ->setLastname($lastname) + ->setAddress1($address1) + ->setAddress2($address2) + ->setAddress3($address3) + ->setPhone($phone) + ->setCellphone($cellphone) + ->setZipcode($zipcode) + ->setCountryId($countryId) + ->setEmail($email) + ->setPassword($plainPassword) + ->setReseller($reseller) + ->setSponsor($sponsor) + ->setDiscount($discount) + ; + } + + public function setPassword($password) + { + $this->setAlgo("PASSWORD_BCRYPT"); + return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + } } diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index b3137152a..45ad06a3d 100644 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -9,7 +9,7 @@ {$message} {/form_error} -
+
{/form_field} {form_field form=$form.lastname} @@ -17,7 +17,7 @@ {$message} {/form_error} -
+
{/form_field} {form_field form=$form.address1} @@ -25,7 +25,7 @@ {$message} {/form_error} -
+
{/form_field} {form_field form=$form.address2} @@ -33,7 +33,7 @@ {$message} {/form_error} -
+
{/form_field} {form_field form=$form.address3} @@ -41,7 +41,7 @@ {$message} {/form_error} -
+
{/form_field} {form_field form=$form.zipcode} @@ -49,7 +49,15 @@ {$message} {/form_error} -
+
+ {/form_field} + + {form_field form=$form.city} + {form_error form=$form.city} + {$message} + {/form_error} + +
{/form_field} {form_field form=$form.country} @@ -66,11 +74,25 @@
{/form_field} + {form_field form=$form.phone} + {form_error form=$form.phone} + {$message} + {/form_error} +
+ {/form_field} + + {form_field form=$form.cellphone} + {form_error form=$form.cellphone} + {$message} + {/form_error} +
+ {/form_field} + {form_field form=$form.email} {form_error form=$form.email} {#message} {/form_error} -
+
{/form_field} {form_field form=$form.email_confirm} From 363e0ab8ae6e00688bb0b789fbf30298872283d9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 15:00:34 +0200 Subject: [PATCH 16/35] fiw non saving customer title --- core/lib/Thelia/Action/Customer.php | 21 +++++++++++++++++++++ core/lib/Thelia/Form/CustomerCreation.php | 6 ++++++ core/lib/Thelia/Model/Customer.php | 4 +++- templates/smarty-sample/connexion.html | 15 +++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index ca0ce3652..d0c96eef5 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -28,6 +28,7 @@ use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\BaseForm; use Thelia\Form\CustomerCreation; +use Thelia\Log\Tlog; class Customer implements EventSubscriberInterface { @@ -48,6 +49,26 @@ class Customer implements EventSubscriberInterface $form->bind($request); if ($form->isValid()) { + $data = $form->getData(); + $customer = new \Thelia\Model\Customer(); + try { + $customer->createOrUpdate( + $data["title"], + $data["firstname"], + $data["lastname"], + $data["address1"], + $data["address2"], + $data["address3"], + $data["phone"], + $data["cellphone"], + $data["zipcode"], + $data["country"], + $data["email"], + $data["password"] + ); + } catch (\PropelException $e) { + Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); + } echo "ok"; exit; } else { diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index 4edd5628e..e2816edc0 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -85,6 +85,12 @@ class CustomerCreation extends BaseForm ), "label" => "country" )) + ->add("title", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "title" + )) ->add("email", "email", array( "constraints" => array( new Constraints\NotBlank(), diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 885d867b0..b78a09cd0 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -18,9 +18,10 @@ use Thelia\Model\om\BaseCustomer; */ class Customer extends BaseCustomer { - public function create($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) { $this + ->setCustomerTitleId($titleId) ->setFirstname($firstname) ->setLastname($lastname) ->setAddress1($address1) @@ -35,6 +36,7 @@ class Customer extends BaseCustomer ->setReseller($reseller) ->setSponsor($sponsor) ->setDiscount($discount) + ->save() ; } diff --git a/templates/smarty-sample/connexion.html b/templates/smarty-sample/connexion.html index 45ad06a3d..44b13386e 100644 --- a/templates/smarty-sample/connexion.html +++ b/templates/smarty-sample/connexion.html @@ -4,6 +4,21 @@
{form_field_hidden form=$form} + + {form_field form=$form.title} + {form_error form=$form.title} + {$message} + {/form_error} + + + +
+ {/form_field} + {form_field form=$form.firstname} {form_error form=$form.firstname} {$message} From aa2ebdc56c56d12a3bdc0ea828965d44841b8cad Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 17:18:10 +0200 Subject: [PATCH 17/35] allow to change programmatically customer ref using event dispatcher --- core/lib/Thelia/Core/Event/TheliaEvents.php | 2 ++ core/lib/Thelia/Model/Customer.php | 31 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 8f44d7fb5..aca4e106a 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -51,4 +51,6 @@ final class TheliaEvents const BEFORE_CREATECUSTOMER = "action.before_createcustomer"; const AFTER_CREATECUSTOMER = "action.after_createcustomer"; + + const CREATECUSTOMER_CUSTOMREF = "customer.creation.customref"; } diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index b78a09cd0..fdd2b7b6c 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -2,6 +2,8 @@ namespace Thelia\Model; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Thelia\Core\Event\CustomRefEvent; use Thelia\Model\om\BaseCustomer; @@ -18,6 +20,12 @@ use Thelia\Model\om\BaseCustomer; */ class Customer extends BaseCustomer { + + /** + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface + */ + protected $dispatcher; + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) { $this @@ -41,9 +49,32 @@ class Customer extends BaseCustomer } + public function preInsert(\PropelPDO $con = null) + { + $customeRef = new CustomRefEvent($this); + if (!is_null($this->dispatcher)) { + $customeRef = new CustomRefEvent($this); + $this->dispatcher->dispatch("customer.creation.customref", $customeRef); + } + + $this->setRef($customeRef->hasRef()? $customeRef->getRef() : $this->generateRef()); + + return false; + } + + protected function generateRef() + { + return date("YmdHI"); + } + public function setPassword($password) { $this->setAlgo("PASSWORD_BCRYPT"); return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); } + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } } From 34d7629c1dda406395cb967a3bac0c0a36d6a2c9 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 17:19:13 +0200 Subject: [PATCH 18/35] add untrack file for before commit --- core/lib/Thelia/Core/Event/CustomRefEvent.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 core/lib/Thelia/Core/Event/CustomRefEvent.php diff --git a/core/lib/Thelia/Core/Event/CustomRefEvent.php b/core/lib/Thelia/Core/Event/CustomRefEvent.php new file mode 100644 index 000000000..15113c218 --- /dev/null +++ b/core/lib/Thelia/Core/Event/CustomRefEvent.php @@ -0,0 +1,53 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Core\Event; + + +use Symfony\Component\EventDispatcher\Event; +use Thelia\Model\Customer; + +class CustomRefEvent extends Event { + protected $ref; + public $customer; + + + public function __construct(Customer $customer) + { + $this->customer = $customer; + } + + public function hasRef() + { + return null !== $this->ref; + } + + public function getRef() + { + return $this->ref; + } + + public function setRef($ref) + { + $this->ref = $ref; + } +} \ No newline at end of file From 1128c10fa81f78acd9e0951de6dc639e32d05b1a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 17:22:54 +0200 Subject: [PATCH 19/35] fix typo --- core/lib/Thelia/Model/Customer.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index fdd2b7b6c..0f68475a4 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -51,13 +51,12 @@ class Customer extends BaseCustomer public function preInsert(\PropelPDO $con = null) { - $customeRef = new CustomRefEvent($this); + $customerRef = new CustomRefEvent($this); if (!is_null($this->dispatcher)) { - $customeRef = new CustomRefEvent($this); - $this->dispatcher->dispatch("customer.creation.customref", $customeRef); + $this->dispatcher->dispatch("customer.creation.customref", $customerRef); } - $this->setRef($customeRef->hasRef()? $customeRef->getRef() : $this->generateRef()); + $this->setRef($customerRef->hasRef()? $customerRef->getRef() : $this->generateRef()); return false; } From 09e8cb4a98d74cad23cec2691e48fed173940fe7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 17:23:45 +0200 Subject: [PATCH 20/35] change return in customer::preInsert model --- core/lib/Thelia/Model/Customer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 0f68475a4..d0f7b8515 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -58,7 +58,7 @@ class Customer extends BaseCustomer $this->setRef($customerRef->hasRef()? $customerRef->getRef() : $this->generateRef()); - return false; + return true; } protected function generateRef() From dcb3baaf4c434c658c95f53de06cd520f2b6ba3d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 2 Jul 2013 17:26:41 +0200 Subject: [PATCH 21/35] change text name event by using TheliaEvents constant --- core/lib/Thelia/Model/Customer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index d0f7b8515..1aef516b7 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -4,6 +4,7 @@ namespace Thelia\Model; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\CustomRefEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Model\om\BaseCustomer; @@ -53,7 +54,7 @@ class Customer extends BaseCustomer { $customerRef = new CustomRefEvent($this); if (!is_null($this->dispatcher)) { - $this->dispatcher->dispatch("customer.creation.customref", $customerRef); + $this->dispatcher->dispatch(TheliaEvents::CREATECUSTOMER_CUSTOMREF, $customerRef); } $this->setRef($customerRef->hasRef()? $customerRef->getRef() : $this->generateRef()); From 42c41d4de1f664fdb7b17efd3054b287d3a43e33 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 09:54:17 +0200 Subject: [PATCH 22/35] add some phpdoc --- core/lib/Thelia/Model/Customer.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 1aef516b7..e295bb215 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -27,6 +27,23 @@ class Customer extends BaseCustomer */ protected $dispatcher; + /** + * @param int $titleId customer title id (from customer_title table) + * @param string $firstname customer first name + * @param string $lastname customer last name + * @param string $address1 customer address + * @param string $address2 customer adress complement 1 + * @param string $address3 customer adress complement 2 + * @param string $phone customer phone number + * @param string $cellphone customer cellphone number + * @param string $zipcode customer zipcode + * @param int $countryId customer country id (from Country table) + * @param string $email customer email, must be unique + * @param string $plainPassword customer plain password, hash is made calling setPassword method + * @param int $reseller + * @param null $sponsor + * @param int $discount + */ public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) { $this From ad8fa59e9a8a5b8f91a701d9750aaf74e61a598d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 10:11:40 +0200 Subject: [PATCH 23/35] put form in error if saving customer fails --- core/lib/Thelia/Action/Customer.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index d0c96eef5..31bfd16ab 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -68,9 +68,11 @@ class Customer implements EventSubscriberInterface ); } catch (\PropelException $e) { Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); + $event->setFormError($form); } - echo "ok"; exit; + //Customer is create, he is automatically connected + } else { $event->setFormError($form); From 8b8ea994ef7012f282df201ed986e9064914ab16 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 10:33:25 +0200 Subject: [PATCH 24/35] allow to reuse creation customer method for modification. Password is not mandatory --- core/lib/Thelia/Model/Customer.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index e295bb215..ca3cc7882 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -2,6 +2,7 @@ namespace Thelia\Model; +use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\CustomRefEvent; use Thelia\Core\Event\TheliaEvents; @@ -39,12 +40,12 @@ class Customer extends BaseCustomer * @param string $zipcode customer zipcode * @param int $countryId customer country id (from Country table) * @param string $email customer email, must be unique - * @param string $plainPassword customer plain password, hash is made calling setPassword method + * @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password * @param int $reseller * @param null $sponsor * @param int $discount */ - public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword, $reseller = 0, $sponsor = null, $discount = 0 ) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $reseller = 0, $sponsor = null, $discount = 0 ) { $this ->setCustomerTitleId($titleId) @@ -86,8 +87,15 @@ class Customer extends BaseCustomer public function setPassword($password) { - $this->setAlgo("PASSWORD_BCRYPT"); - return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + if ($this->isNew() && ($password === null || trim($password) == "")) { + throw new InvalidArgumentException("customer password is mandatory on creation"); + } + + if($password !== null && trim($password) != "") { + $this->setAlgo("PASSWORD_BCRYPT"); + return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + } + } public function setDispatcher(EventDispatcherInterface $dispatcher) From bc6545e91486efe9493ea8e2df633071eeb6d96b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 14:38:06 +0200 Subject: [PATCH 25/35] create class form for customer modification --- core/lib/Thelia/Action/Customer.php | 40 +++++- core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Form/BaseForm.php | 2 +- core/lib/Thelia/Form/CustomerModification.php | 120 ++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 core/lib/Thelia/Form/CustomerModification.php diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 31bfd16ab..e3481bdce 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -28,7 +28,10 @@ use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\BaseForm; use Thelia\Form\CustomerCreation; +use Thelia\Form\CustomerModification; +use Thelia\Model\Customer as CustomerModel; use Thelia\Log\Tlog; +use Thelia\Model\CustomerQuery; class Customer implements EventSubscriberInterface { @@ -50,7 +53,7 @@ class Customer implements EventSubscriberInterface if ($form->isValid()) { $data = $form->getData(); - $customer = new \Thelia\Model\Customer(); + $customer = new CustomerModel(); try { $customer->createOrUpdate( $data["title"], @@ -84,6 +87,41 @@ class Customer implements EventSubscriberInterface public function modify(ActionEvent $event) { + $request = $event->getRequest(); + + $customerModification = new CustomerModification($request); + + $form = $customerModification->getForm(); + + if ($request->isMethod("post")) { + $form->bind($request); + + if ($form->isValid()) { + $data = $form->getData(); + + $customer = CustomerQuery::create()->findPk(1); + try { + $data = $form->getData(); + $customer->createOrUpdate( + $data["title"], + $data["firstname"], + $data["lastname"], + $data["address1"], + $data["address2"], + $data["address3"], + $data["phone"], + $data["cellphone"], + $data["zipcode"], + $data["country"] + ); + } catch(\PropelException $e) { + Tlog::getInstance()->error(sprintf('error during modifying customer on action/modifyCustomer with message "%s"', $e->getMessage())); + $event->setFormError($form); + } + } else { + $event->setFormError($form); + } + } } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 4eb0217ae..6f9ec52f6 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -23,6 +23,7 @@ + diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 3a6d69cb3..0b034345b 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -89,7 +89,7 @@ abstract class BaseForm { * ), * "label" => "email", * "constraints" => array( - * new NotBlank() + * new \Symfony\Component\Validator\Constraints\NotBlank() * ) * ) * ) diff --git a/core/lib/Thelia/Form/CustomerModification.php b/core/lib/Thelia/Form/CustomerModification.php new file mode 100644 index 000000000..df699c873 --- /dev/null +++ b/core/lib/Thelia/Form/CustomerModification.php @@ -0,0 +1,120 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Thelia\Model\Customer; + + +class CustomerModification extends BaseForm { + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->form attribute : + * + * $this->form->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + + $this->form + ->add("firstname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "firstname" + )) + ->add("lastname", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "lastname" + )) + ->add("address1", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "address" + )) + ->add("address2", "text", array( + "label" => "Address Line 2" + )) + ->add("address3", "text", array( + "label" => "Address Line 3" + )) + ->add("phone", "text", array( + "label" => "phone" + )) + ->add("cellphone", "text", array( + "label" => "cellphone" + )) + ->add("zipcode", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "zipcode" + )) + ->add("city", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "city" + )) + ->add("country", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "country" + )) + ->add("title", "text", array( + "constraints" => array( + new Constraints\NotBlank() + ), + "label" => "title" + )) + ; + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "customerModification"; + } +} \ No newline at end of file From 89ca995f29b0d2f1c5eafa9829a70694c64263c7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 14:45:18 +0200 Subject: [PATCH 26/35] fix typo in phpdoc --- core/lib/Thelia/Form/BaseForm.php | 1 - core/lib/Thelia/Form/CustomerModification.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 0b034345b..b53747a5d 100644 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -30,7 +30,6 @@ use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension; use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; use Symfony\Component\Validator\Validation; -use Thelia\Form\Extension\NameFormExtension; use Thelia\Model\ConfigQuery; abstract class BaseForm { diff --git a/core/lib/Thelia/Form/CustomerModification.php b/core/lib/Thelia/Form/CustomerModification.php index df699c873..cb21be2fa 100644 --- a/core/lib/Thelia/Form/CustomerModification.php +++ b/core/lib/Thelia/Form/CustomerModification.php @@ -4,7 +4,7 @@ /* Thelia */ /* */ /* Copyright (c) OpenStudio */ -/* email : info@thelia.net */ +/* email : info@thelia.net */ /* web : http://www.thelia.net */ /* */ /* This program is free software; you can redistribute it and/or modify */ @@ -17,7 +17,7 @@ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ -/* along with this program. If not, see . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ From 0d1e0c6a2c945ff152a9404d7e575f7a440ef71b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 3 Jul 2013 15:05:08 +0200 Subject: [PATCH 27/35] fiw typo in schema model --- core/lib/Thelia/Action/Customer.php | 1 + core/lib/Thelia/Form/CustomerCreation.php | 2 ++ core/lib/Thelia/Model/Customer.php | 1 + install/thelia.sql | 4 ++-- local/config/schema.xml | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index e3481bdce..94d27793a 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -55,6 +55,7 @@ class Customer implements EventSubscriberInterface $data = $form->getData(); $customer = new CustomerModel(); try { + \Thelia\Log\Tlog::getInstance()->debug($data); $customer->createOrUpdate( $data["title"], $data["firstname"], diff --git a/core/lib/Thelia/Form/CustomerCreation.php b/core/lib/Thelia/Form/CustomerCreation.php index e2816edc0..b151fc98d 100644 --- a/core/lib/Thelia/Form/CustomerCreation.php +++ b/core/lib/Thelia/Form/CustomerCreation.php @@ -117,12 +117,14 @@ class CustomerCreation extends BaseForm )) ->add("password", "password", array( "constraints" => array( + new Constraints\NotBlank(), new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) ), "label" => "password" )) ->add("password_confirm", "password", array( "constraints" => array( + new Constraints\NotBlank(), new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), new Constraints\Callback(array("methods" => array( array($this, "verifyPasswordField") diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index ca3cc7882..20146cd94 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -87,6 +87,7 @@ class Customer extends BaseCustomer public function setPassword($password) { + \Thelia\Log\Tlog::getInstance()->debug($password); if ($this->isNew() && ($password === null || trim($password) == "")) { throw new InvalidArgumentException("customer password is mandatory on creation"); } diff --git a/install/thelia.sql b/install/thelia.sql index 46a934a3b..94d933587 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -477,8 +477,8 @@ CREATE TABLE `customer` `updated_at` DATETIME, PRIMARY KEY (`id`), UNIQUE INDEX `ref_UNIQUE` (`ref`), - INDEX `idx_ customer_customer_title_id` (`customer_title_id`), - CONSTRAINT `fk_ customer_customer_title_id` + INDEX `idx_customer_customer_title_id` (`customer_title_id`), + CONSTRAINT `fk_customer_customer_title_id` FOREIGN KEY (`customer_title_id`) REFERENCES `customer_title` (`id`) ON UPDATE RESTRICT diff --git a/local/config/schema.xml b/local/config/schema.xml index f9063c614..8b97f4e8c 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -349,7 +349,7 @@ - + From b7a8648c108fe6ee44ed6a17f4c510af108ddefa Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 4 Jul 2013 18:10:08 +0200 Subject: [PATCH 28/35] start lang management --- core/lib/Thelia/Core/TheliaHttpKernel.php | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index c315662e0..e04009301 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -119,6 +119,59 @@ class TheliaHttpKernel extends HttpKernel */ protected function initParam(Request $request) { + $lang = $this->detectLang($request); + + if ($lang) { + $request->getSession()->set("lang", $lang->getCode()); + $request->getSession()->set("locale", $lang->getLocale()); + } + } + + /** + * @param Request $request + * @return null|\Thelia\Model\Lang + */ + protected function detectLang(Request $request) + { + $lang = null; + //first priority => lang parameter present in request (get or post) + if($request->query->has("lang")) { + $lang = Model\LangQuery::create()->findOneByCode($request->query->get("lang")); + + if(is_null($lang)) { + return; + } + + //if each lang had is own domain, we redirect the user to the good one. + if (Model\ConfigQuery::read("one_domain_foreach_lang", false) == 1) { + //if lang domain is different from actuel domain, redirect to the good one + if (rtrim($lang->getUrl(), "/") != $request->getSchemeAndHttpHost()) { + // TODO : search if http status 302 is the good one. + $redirect = new RedirectResponse($lang->getUrl(), 302); + $redirect->send(); + exit; + } else { + //the user is actually on the good domain, nothing to change + return null; + } + } else { + //one domain for all languages, the lang is set into session + return $lang; + } + } + + //check if lang is not defined. If not we have to search the good one. + if (null === $request->getSession()->get("lang")) { + + if (Model\ConfigQuery::read("one_domain_foreach_lang", false) == 1) { + //find lang with domain + return Model\LangQuery::create()->filterByUrl($request->getSchemeAndHttpHost(), \Criteria::LIKE)->findOne(); + } + + //find default lang + return Model\LangQuery::create()->findOneByByDefault(1); + + } } From ca44544f84549d0e6a65443239b491afdfaf810d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 4 Jul 2013 18:21:24 +0200 Subject: [PATCH 29/35] manage lang for customer --- core/lib/Thelia/Action/Customer.php | 3 ++- core/lib/Thelia/Core/TheliaHttpKernel.php | 1 + core/lib/Thelia/Model/Customer.php | 9 +++++++-- templates/smarty-sample/index.html | 21 ++------------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 94d27793a..98341ee28 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -68,7 +68,8 @@ class Customer implements EventSubscriberInterface $data["zipcode"], $data["country"], $data["email"], - $data["password"] + $data["password"], + $request->getSession()->get("lang") ); } catch (\PropelException $e) { Tlog::getInstance()->error(sprintf('error during creating customer on action/createCustomer with message "%s"', $e->getMessage())); diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index e04009301..0af91fa08 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -76,6 +76,7 @@ class TheliaHttpKernel extends HttpKernel { //$request->headers->set('X-Php-Ob-Level', ob_get_level()); $request = $this->initSession($request); + $this->initParam($request); $this->container->enterScope('request'); $this->container->set('request', $request, 'request'); diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index 20146cd94..197df4c7c 100755 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -45,7 +45,7 @@ class Customer extends BaseCustomer * @param null $sponsor * @param int $discount */ - public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $reseller = 0, $sponsor = null, $discount = 0 ) + public function createOrUpdate($titleId, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $countryId, $email, $plainPassword = null, $lang = null, $reseller = 0, $sponsor = null, $discount = 0) { $this ->setCustomerTitleId($titleId) @@ -63,9 +63,14 @@ class Customer extends BaseCustomer ->setReseller($reseller) ->setSponsor($sponsor) ->setDiscount($discount) - ->save() ; + if(!is_null($lang)) { + $this->setLang($lang); + } + + $this->save(); + } public function preInsert(\PropelPDO $con = null) diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index d7c2b2e62..77ba1e978 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -13,22 +13,7 @@ An image from asset directory : jQuery data: -
-

Category loop example

-
    - {loop type="category" name="catloop1"} -
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}, children: {$NB_CHILD} - {ifloop rel="inner1"} -
      - {loop type="category" name="inner1" parent="{$ID}"} -
    • Sub cat {$ID} (parent is {$PARENT}): {$TITLE}
    • - {/loop} -
    - {/ifloop} -
  • - {/loop} -
-
+

Conditional example #1

@@ -66,9 +51,7 @@ An image from asset directory : {elseloop rel="catloop2"}

... but catloop2 is still empty :-)

{/elseloop} - {ifloop rel="catloop1"} -

... and catloop1 is still NOT empty :-)

- {/ifloop} +
From abe60649551acbaee0f546b9b3140b3ffeb09b04 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 4 Jul 2013 18:47:20 +0200 Subject: [PATCH 30/35] allow to display result or not if translation is present --- core/lib/Thelia/Core/Template/Loop/Category.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 55be4d69a..90de19e1c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -32,6 +32,7 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Log\Tlog; use Thelia\Model\CategoryQuery; +use Thelia\Model\ConfigQuery; use Thelia\Type\TypeCollection; use Thelia\Type; @@ -156,7 +157,10 @@ class Category extends BaseLoop * * @todo : verify here if we want results for row without translations. */ - $search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN); + $search->joinWithI18n( + $this->request->getSession()->get('locale', 'en_US'), + (ConfigQuery::read("default_lang_without_translation", 1)) ? \Criteria::LEFT_JOIN : \Criteria::INNER_JOIN + ); $categories = $this->search($search, $pagination); From 5fda702b8dee09db3f6f2bee9f4bf84927b4b9ee Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 4 Jul 2013 19:31:09 +0200 Subject: [PATCH 31/35] migrte propel to propel 2 --- composer.json | 2 +- core/lib/Thelia/Config/DefinePropel.php | 18 +- .../Thelia/Core/Template/Element/BaseLoop.php | 7 +- .../Thelia/Core/Template/Loop/Category.php | 9 +- core/lib/Thelia/Core/Thelia.php | 17 +- core/lib/Thelia/Model/Accessory.php | 16 +- core/lib/Thelia/Model/AccessoryPeer.php | 21 - core/lib/Thelia/Model/AccessoryQuery.php | 9 +- core/lib/Thelia/Model/Address.php | 16 +- core/lib/Thelia/Model/AddressPeer.php | 21 - core/lib/Thelia/Model/AddressQuery.php | 9 +- core/lib/Thelia/Model/Admin.php | 16 +- core/lib/Thelia/Model/AdminGroup.php | 16 +- core/lib/Thelia/Model/AdminGroupPeer.php | 21 - core/lib/Thelia/Model/AdminGroupQuery.php | 9 +- core/lib/Thelia/Model/AdminLog.php | 16 +- core/lib/Thelia/Model/AdminLogPeer.php | 21 - core/lib/Thelia/Model/AdminLogQuery.php | 9 +- core/lib/Thelia/Model/AdminPeer.php | 21 - core/lib/Thelia/Model/AdminQuery.php | 9 +- core/lib/Thelia/Model/Area.php | 16 +- core/lib/Thelia/Model/AreaPeer.php | 21 - core/lib/Thelia/Model/AreaQuery.php | 9 +- core/lib/Thelia/Model/Attribute.php | 16 +- core/lib/Thelia/Model/AttributeAv.php | 16 +- core/lib/Thelia/Model/AttributeAvI18n.php | 16 +- core/lib/Thelia/Model/AttributeAvI18nPeer.php | 21 - .../lib/Thelia/Model/AttributeAvI18nQuery.php | 9 +- core/lib/Thelia/Model/AttributeAvPeer.php | 21 - core/lib/Thelia/Model/AttributeAvQuery.php | 9 +- core/lib/Thelia/Model/AttributeCategory.php | 16 +- .../Thelia/Model/AttributeCategoryPeer.php | 21 - .../Thelia/Model/AttributeCategoryQuery.php | 9 +- .../lib/Thelia/Model/AttributeCombination.php | 16 +- .../Thelia/Model/AttributeCombinationPeer.php | 21 - .../Model/AttributeCombinationQuery.php | 9 +- core/lib/Thelia/Model/AttributeI18n.php | 16 +- core/lib/Thelia/Model/AttributeI18nPeer.php | 21 - core/lib/Thelia/Model/AttributeI18nQuery.php | 9 +- core/lib/Thelia/Model/AttributePeer.php | 21 - core/lib/Thelia/Model/AttributeQuery.php | 9 +- core/lib/Thelia/Model/Category.php | 20 +- core/lib/Thelia/Model/CategoryI18n.php | 16 +- core/lib/Thelia/Model/CategoryI18nPeer.php | 21 - core/lib/Thelia/Model/CategoryI18nQuery.php | 9 +- core/lib/Thelia/Model/CategoryPeer.php | 21 - core/lib/Thelia/Model/CategoryQuery.php | 11 +- core/lib/Thelia/Model/CategoryVersion.php | 16 +- core/lib/Thelia/Model/CategoryVersionPeer.php | 21 - .../lib/Thelia/Model/CategoryVersionQuery.php | 9 +- core/lib/Thelia/Model/Combination.php | 16 +- core/lib/Thelia/Model/CombinationPeer.php | 21 - core/lib/Thelia/Model/CombinationQuery.php | 9 +- core/lib/Thelia/Model/Config.php | 16 +- core/lib/Thelia/Model/ConfigI18n.php | 16 +- core/lib/Thelia/Model/ConfigI18nPeer.php | 21 - core/lib/Thelia/Model/ConfigI18nQuery.php | 9 +- core/lib/Thelia/Model/ConfigPeer.php | 21 - core/lib/Thelia/Model/ConfigQuery.php | 8 +- core/lib/Thelia/Model/Content.php | 16 +- core/lib/Thelia/Model/ContentAssoc.php | 16 +- core/lib/Thelia/Model/ContentAssocPeer.php | 21 - core/lib/Thelia/Model/ContentAssocQuery.php | 9 +- core/lib/Thelia/Model/ContentFolder.php | 16 +- core/lib/Thelia/Model/ContentFolderPeer.php | 21 - core/lib/Thelia/Model/ContentFolderQuery.php | 9 +- core/lib/Thelia/Model/ContentI18n.php | 16 +- core/lib/Thelia/Model/ContentI18nPeer.php | 21 - core/lib/Thelia/Model/ContentI18nQuery.php | 9 +- core/lib/Thelia/Model/ContentPeer.php | 21 - core/lib/Thelia/Model/ContentQuery.php | 9 +- core/lib/Thelia/Model/ContentVersion.php | 16 +- core/lib/Thelia/Model/ContentVersionPeer.php | 21 - core/lib/Thelia/Model/ContentVersionQuery.php | 9 +- core/lib/Thelia/Model/Country.php | 16 +- core/lib/Thelia/Model/CountryI18n.php | 16 +- core/lib/Thelia/Model/CountryI18nPeer.php | 21 - core/lib/Thelia/Model/CountryI18nQuery.php | 9 +- core/lib/Thelia/Model/CountryPeer.php | 21 - core/lib/Thelia/Model/CountryQuery.php | 9 +- core/lib/Thelia/Model/Coupon.php | 16 +- core/lib/Thelia/Model/CouponOrder.php | 16 +- core/lib/Thelia/Model/CouponOrderPeer.php | 21 - core/lib/Thelia/Model/CouponOrderQuery.php | 9 +- core/lib/Thelia/Model/CouponPeer.php | 21 - core/lib/Thelia/Model/CouponQuery.php | 9 +- core/lib/Thelia/Model/CouponRule.php | 16 +- core/lib/Thelia/Model/CouponRulePeer.php | 21 - core/lib/Thelia/Model/CouponRuleQuery.php | 9 +- core/lib/Thelia/Model/Currency.php | 16 +- core/lib/Thelia/Model/CurrencyPeer.php | 21 - core/lib/Thelia/Model/CurrencyQuery.php | 9 +- core/lib/Thelia/Model/Customer.php | 57 +- core/lib/Thelia/Model/CustomerPeer.php | 21 - core/lib/Thelia/Model/CustomerQuery.php | 8 +- core/lib/Thelia/Model/CustomerTitle.php | 16 +- core/lib/Thelia/Model/CustomerTitleI18n.php | 16 +- .../Thelia/Model/CustomerTitleI18nPeer.php | 21 - .../Thelia/Model/CustomerTitleI18nQuery.php | 9 +- core/lib/Thelia/Model/CustomerTitlePeer.php | 21 - core/lib/Thelia/Model/CustomerTitleQuery.php | 9 +- core/lib/Thelia/Model/Delivzone.php | 16 +- core/lib/Thelia/Model/DelivzonePeer.php | 21 - core/lib/Thelia/Model/DelivzoneQuery.php | 9 +- core/lib/Thelia/Model/Document.php | 16 +- core/lib/Thelia/Model/DocumentI18n.php | 16 +- core/lib/Thelia/Model/DocumentI18nPeer.php | 21 - core/lib/Thelia/Model/DocumentI18nQuery.php | 9 +- core/lib/Thelia/Model/DocumentPeer.php | 21 - core/lib/Thelia/Model/DocumentQuery.php | 9 +- core/lib/Thelia/Model/Feature.php | 16 +- core/lib/Thelia/Model/FeatureAv.php | 16 +- core/lib/Thelia/Model/FeatureAvI18n.php | 16 +- core/lib/Thelia/Model/FeatureAvI18nPeer.php | 21 - core/lib/Thelia/Model/FeatureAvI18nQuery.php | 9 +- core/lib/Thelia/Model/FeatureAvPeer.php | 21 - core/lib/Thelia/Model/FeatureAvQuery.php | 9 +- core/lib/Thelia/Model/FeatureCategory.php | 16 +- core/lib/Thelia/Model/FeatureCategoryPeer.php | 21 - .../lib/Thelia/Model/FeatureCategoryQuery.php | 9 +- core/lib/Thelia/Model/FeatureI18n.php | 16 +- core/lib/Thelia/Model/FeatureI18nPeer.php | 21 - core/lib/Thelia/Model/FeatureI18nQuery.php | 9 +- core/lib/Thelia/Model/FeaturePeer.php | 21 - core/lib/Thelia/Model/FeatureProd.php | 16 +- core/lib/Thelia/Model/FeatureProdPeer.php | 21 - core/lib/Thelia/Model/FeatureProdQuery.php | 9 +- core/lib/Thelia/Model/FeatureQuery.php | 9 +- core/lib/Thelia/Model/Folder.php | 16 +- core/lib/Thelia/Model/FolderI18n.php | 16 +- core/lib/Thelia/Model/FolderI18nPeer.php | 21 - core/lib/Thelia/Model/FolderI18nQuery.php | 9 +- core/lib/Thelia/Model/FolderPeer.php | 21 - core/lib/Thelia/Model/FolderQuery.php | 9 +- core/lib/Thelia/Model/FolderVersion.php | 16 +- core/lib/Thelia/Model/FolderVersionPeer.php | 21 - core/lib/Thelia/Model/FolderVersionQuery.php | 9 +- core/lib/Thelia/Model/Group.php | 16 +- core/lib/Thelia/Model/GroupI18n.php | 16 +- core/lib/Thelia/Model/GroupI18nPeer.php | 21 - core/lib/Thelia/Model/GroupI18nQuery.php | 9 +- core/lib/Thelia/Model/GroupModule.php | 16 +- core/lib/Thelia/Model/GroupModulePeer.php | 21 - core/lib/Thelia/Model/GroupModuleQuery.php | 9 +- core/lib/Thelia/Model/GroupPeer.php | 21 - core/lib/Thelia/Model/GroupQuery.php | 9 +- core/lib/Thelia/Model/GroupResource.php | 16 +- core/lib/Thelia/Model/GroupResourcePeer.php | 21 - core/lib/Thelia/Model/GroupResourceQuery.php | 9 +- core/lib/Thelia/Model/Image.php | 16 +- core/lib/Thelia/Model/ImageI18n.php | 16 +- core/lib/Thelia/Model/ImageI18nPeer.php | 21 - core/lib/Thelia/Model/ImageI18nQuery.php | 9 +- core/lib/Thelia/Model/ImagePeer.php | 21 - core/lib/Thelia/Model/ImageQuery.php | 9 +- core/lib/Thelia/Model/Lang.php | 16 +- core/lib/Thelia/Model/LangPeer.php | 21 - core/lib/Thelia/Model/LangQuery.php | 9 +- core/lib/Thelia/Model/Message.php | 16 +- core/lib/Thelia/Model/MessageI18n.php | 16 +- core/lib/Thelia/Model/MessageI18nPeer.php | 21 - core/lib/Thelia/Model/MessageI18nQuery.php | 9 +- core/lib/Thelia/Model/MessagePeer.php | 21 - core/lib/Thelia/Model/MessageQuery.php | 9 +- core/lib/Thelia/Model/MessageVersion.php | 16 +- core/lib/Thelia/Model/MessageVersionPeer.php | 21 - core/lib/Thelia/Model/MessageVersionQuery.php | 9 +- core/lib/Thelia/Model/Module.php | 16 +- core/lib/Thelia/Model/ModuleI18n.php | 16 +- core/lib/Thelia/Model/ModuleI18nPeer.php | 21 - core/lib/Thelia/Model/ModuleI18nQuery.php | 9 +- core/lib/Thelia/Model/ModulePeer.php | 21 - core/lib/Thelia/Model/ModuleQuery.php | 12 +- core/lib/Thelia/Model/Order.php | 16 +- core/lib/Thelia/Model/OrderAddress.php | 16 +- core/lib/Thelia/Model/OrderAddressPeer.php | 21 - core/lib/Thelia/Model/OrderAddressQuery.php | 9 +- core/lib/Thelia/Model/OrderFeature.php | 16 +- core/lib/Thelia/Model/OrderFeaturePeer.php | 21 - core/lib/Thelia/Model/OrderFeatureQuery.php | 9 +- core/lib/Thelia/Model/OrderPeer.php | 21 - core/lib/Thelia/Model/OrderProduct.php | 16 +- core/lib/Thelia/Model/OrderProductPeer.php | 21 - core/lib/Thelia/Model/OrderProductQuery.php | 9 +- core/lib/Thelia/Model/OrderQuery.php | 9 +- core/lib/Thelia/Model/OrderStatus.php | 16 +- core/lib/Thelia/Model/OrderStatusI18n.php | 16 +- core/lib/Thelia/Model/OrderStatusI18nPeer.php | 21 - .../lib/Thelia/Model/OrderStatusI18nQuery.php | 9 +- core/lib/Thelia/Model/OrderStatusPeer.php | 21 - core/lib/Thelia/Model/OrderStatusQuery.php | 9 +- core/lib/Thelia/Model/Product.php | 16 +- core/lib/Thelia/Model/ProductCategory.php | 16 +- core/lib/Thelia/Model/ProductCategoryPeer.php | 21 - .../lib/Thelia/Model/ProductCategoryQuery.php | 9 +- core/lib/Thelia/Model/ProductI18n.php | 16 +- core/lib/Thelia/Model/ProductI18nPeer.php | 21 - core/lib/Thelia/Model/ProductI18nQuery.php | 9 +- core/lib/Thelia/Model/ProductPeer.php | 21 - core/lib/Thelia/Model/ProductQuery.php | 9 +- core/lib/Thelia/Model/ProductVersion.php | 16 +- core/lib/Thelia/Model/ProductVersionPeer.php | 21 - core/lib/Thelia/Model/ProductVersionQuery.php | 9 +- core/lib/Thelia/Model/Resource.php | 16 +- core/lib/Thelia/Model/ResourceI18n.php | 16 +- core/lib/Thelia/Model/ResourceI18nPeer.php | 21 - core/lib/Thelia/Model/ResourceI18nQuery.php | 9 +- core/lib/Thelia/Model/ResourcePeer.php | 21 - core/lib/Thelia/Model/ResourceQuery.php | 9 +- core/lib/Thelia/Model/Rewriting.php | 16 +- core/lib/Thelia/Model/RewritingPeer.php | 21 - core/lib/Thelia/Model/RewritingQuery.php | 9 +- core/lib/Thelia/Model/Stock.php | 16 +- core/lib/Thelia/Model/StockPeer.php | 21 - core/lib/Thelia/Model/StockQuery.php | 9 +- core/lib/Thelia/Model/Tax.php | 16 +- core/lib/Thelia/Model/TaxI18n.php | 16 +- core/lib/Thelia/Model/TaxI18nPeer.php | 21 - core/lib/Thelia/Model/TaxI18nQuery.php | 9 +- core/lib/Thelia/Model/TaxPeer.php | 21 - core/lib/Thelia/Model/TaxQuery.php | 9 +- core/lib/Thelia/Model/TaxRule.php | 16 +- core/lib/Thelia/Model/TaxRuleCountry.php | 16 +- core/lib/Thelia/Model/TaxRuleCountryPeer.php | 21 - core/lib/Thelia/Model/TaxRuleCountryQuery.php | 9 +- core/lib/Thelia/Model/TaxRuleI18n.php | 16 +- core/lib/Thelia/Model/TaxRuleI18nPeer.php | 21 - core/lib/Thelia/Model/TaxRuleI18nQuery.php | 9 +- core/lib/Thelia/Model/TaxRulePeer.php | 21 - core/lib/Thelia/Model/TaxRuleQuery.php | 9 +- .../Thelia/Model/map/AccessoryTableMap.php | 81 - core/lib/Thelia/Model/map/AddressTableMap.php | 90 - .../Thelia/Model/map/AdminGroupTableMap.php | 80 - .../lib/Thelia/Model/map/AdminLogTableMap.php | 80 - core/lib/Thelia/Model/map/AdminTableMap.php | 83 - core/lib/Thelia/Model/map/AreaTableMap.php | 79 - .../Model/map/AttributeAvI18nTableMap.php | 62 - .../Thelia/Model/map/AttributeAvTableMap.php | 89 - .../Model/map/AttributeCategoryTableMap.php | 80 - .../map/AttributeCombinationTableMap.php | 81 - .../Model/map/AttributeI18nTableMap.php | 62 - .../Thelia/Model/map/AttributeTableMap.php | 90 - .../Thelia/Model/map/CategoryI18nTableMap.php | 62 - .../lib/Thelia/Model/map/CategoryTableMap.php | 113 - .../Model/map/CategoryVersionTableMap.php | 66 - .../Thelia/Model/map/CombinationTableMap.php | 78 - .../Thelia/Model/map/ConfigI18nTableMap.php | 62 - core/lib/Thelia/Model/map/ConfigTableMap.php | 89 - .../Thelia/Model/map/ContentAssocTableMap.php | 82 - .../Model/map/ContentFolderTableMap.php | 79 - .../Thelia/Model/map/ContentI18nTableMap.php | 62 - core/lib/Thelia/Model/map/ContentTableMap.php | 107 - .../Model/map/ContentVersionTableMap.php | 64 - .../Thelia/Model/map/CountryI18nTableMap.php | 62 - core/lib/Thelia/Model/map/CountryTableMap.php | 91 - .../Thelia/Model/map/CouponOrderTableMap.php | 79 - .../Thelia/Model/map/CouponRuleTableMap.php | 80 - core/lib/Thelia/Model/map/CouponTableMap.php | 83 - .../lib/Thelia/Model/map/CurrencyTableMap.php | 81 - .../lib/Thelia/Model/map/CustomerTableMap.php | 99 - .../Model/map/CustomerTitleI18nTableMap.php | 60 - .../Model/map/CustomerTitleTableMap.php | 89 - .../Thelia/Model/map/DelivzoneTableMap.php | 78 - .../Thelia/Model/map/DocumentI18nTableMap.php | 62 - .../lib/Thelia/Model/map/DocumentTableMap.php | 95 - .../Model/map/FeatureAvI18nTableMap.php | 62 - .../Thelia/Model/map/FeatureAvTableMap.php | 88 - .../Model/map/FeatureCategoryTableMap.php | 80 - .../Thelia/Model/map/FeatureI18nTableMap.php | 62 - .../Thelia/Model/map/FeatureProdTableMap.php | 83 - core/lib/Thelia/Model/map/FeatureTableMap.php | 91 - .../Thelia/Model/map/FolderI18nTableMap.php | 62 - core/lib/Thelia/Model/map/FolderTableMap.php | 108 - .../Model/map/FolderVersionTableMap.php | 66 - .../Thelia/Model/map/GroupI18nTableMap.php | 62 - .../Thelia/Model/map/GroupModuleTableMap.php | 80 - .../Model/map/GroupResourceTableMap.php | 82 - core/lib/Thelia/Model/map/GroupTableMap.php | 91 - .../Thelia/Model/map/ImageI18nTableMap.php | 62 - core/lib/Thelia/Model/map/ImageTableMap.php | 95 - core/lib/Thelia/Model/map/LangTableMap.php | 80 - .../Thelia/Model/map/MessageI18nTableMap.php | 61 - core/lib/Thelia/Model/map/MessageTableMap.php | 102 - .../Model/map/MessageVersionTableMap.php | 65 - .../Thelia/Model/map/ModuleI18nTableMap.php | 62 - core/lib/Thelia/Model/map/ModuleTableMap.php | 90 - .../Thelia/Model/map/OrderAddressTableMap.php | 88 - .../Thelia/Model/map/OrderFeatureTableMap.php | 79 - .../Thelia/Model/map/OrderProductTableMap.php | 86 - .../Model/map/OrderStatusI18nTableMap.php | 62 - .../Thelia/Model/map/OrderStatusTableMap.php | 87 - core/lib/Thelia/Model/map/OrderTableMap.php | 97 - .../Model/map/ProductCategoryTableMap.php | 79 - .../Thelia/Model/map/ProductI18nTableMap.php | 62 - core/lib/Thelia/Model/map/ProductTableMap.php | 123 - .../Model/map/ProductVersionTableMap.php | 73 - .../Thelia/Model/map/ResourceI18nTableMap.php | 62 - .../lib/Thelia/Model/map/ResourceTableMap.php | 88 - .../Thelia/Model/map/RewritingTableMap.php | 84 - core/lib/Thelia/Model/map/StockTableMap.php | 81 - core/lib/Thelia/Model/map/TaxI18nTableMap.php | 60 - .../Model/map/TaxRuleCountryTableMap.php | 82 - .../Thelia/Model/map/TaxRuleI18nTableMap.php | 58 - core/lib/Thelia/Model/map/TaxRuleTableMap.php | 90 - core/lib/Thelia/Model/map/TaxTableMap.php | 87 - core/lib/Thelia/Model/om/BaseAccessory.php | 1329 ---- .../lib/Thelia/Model/om/BaseAccessoryPeer.php | 1371 ---- .../Thelia/Model/om/BaseAccessoryQuery.php | 749 -- core/lib/Thelia/Model/om/BaseAddress.php | 1892 ----- core/lib/Thelia/Model/om/BaseAddressPeer.php | 1478 ---- core/lib/Thelia/Model/om/BaseAddressQuery.php | 1080 --- core/lib/Thelia/Model/om/BaseAdmin.php | 1868 ----- core/lib/Thelia/Model/om/BaseAdminGroup.php | 1297 ---- .../Thelia/Model/om/BaseAdminGroupPeer.php | 1420 ---- .../Thelia/Model/om/BaseAdminGroupQuery.php | 711 -- core/lib/Thelia/Model/om/BaseAdminLog.php | 1252 ---- core/lib/Thelia/Model/om/BaseAdminLogPeer.php | 805 -- .../lib/Thelia/Model/om/BaseAdminLogQuery.php | 609 -- core/lib/Thelia/Model/om/BaseAdminPeer.php | 814 -- core/lib/Thelia/Model/om/BaseAdminQuery.php | 741 -- core/lib/Thelia/Model/om/BaseArea.php | 1679 ----- core/lib/Thelia/Model/om/BaseAreaPeer.php | 798 -- core/lib/Thelia/Model/om/BaseAreaQuery.php | 683 -- core/lib/Thelia/Model/om/BaseAttribute.php | 2700 ------- core/lib/Thelia/Model/om/BaseAttributeAv.php | 2042 ----- .../Thelia/Model/om/BaseAttributeAvI18n.php | 1187 --- .../Model/om/BaseAttributeAvI18nPeer.php | 1016 --- .../Model/om/BaseAttributeAvI18nQuery.php | 537 -- .../Thelia/Model/om/BaseAttributeAvPeer.php | 1044 --- .../Thelia/Model/om/BaseAttributeAvQuery.php | 836 --- .../Thelia/Model/om/BaseAttributeCategory.php | 1287 ---- .../Model/om/BaseAttributeCategoryPeer.php | 1423 ---- .../Model/om/BaseAttributeCategoryQuery.php | 704 -- .../Model/om/BaseAttributeCombination.php | 1442 ---- .../Model/om/BaseAttributeCombinationPeer.php | 1783 ----- .../om/BaseAttributeCombinationQuery.php | 845 --- .../lib/Thelia/Model/om/BaseAttributeI18n.php | 1187 --- .../Thelia/Model/om/BaseAttributeI18nPeer.php | 1016 --- .../Model/om/BaseAttributeI18nQuery.php | 537 -- .../lib/Thelia/Model/om/BaseAttributePeer.php | 808 -- .../Thelia/Model/om/BaseAttributeQuery.php | 883 --- core/lib/Thelia/Model/om/BaseCategory.php | 5534 -------------- core/lib/Thelia/Model/om/BaseCategoryI18n.php | 1187 --- .../Thelia/Model/om/BaseCategoryI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseCategoryI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseCategoryPeer.php | 893 --- .../lib/Thelia/Model/om/BaseCategoryQuery.php | 1565 ---- .../Thelia/Model/om/BaseCategoryVersion.php | 1505 ---- .../Model/om/BaseCategoryVersionPeer.php | 1036 --- .../Model/om/BaseCategoryVersionQuery.php | 763 -- core/lib/Thelia/Model/om/BaseCombination.php | 1698 ----- .../Thelia/Model/om/BaseCombinationPeer.php | 793 -- .../Thelia/Model/om/BaseCombinationQuery.php | 637 -- core/lib/Thelia/Model/om/BaseConfig.php | 1757 ----- core/lib/Thelia/Model/om/BaseConfigI18n.php | 1187 --- .../Thelia/Model/om/BaseConfigI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseConfigI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseConfigPeer.php | 811 -- core/lib/Thelia/Model/om/BaseConfigQuery.php | 740 -- core/lib/Thelia/Model/om/BaseContent.php | 4358 ----------- core/lib/Thelia/Model/om/BaseContentAssoc.php | 1484 ---- .../Thelia/Model/om/BaseContentAssocPeer.php | 1780 ----- .../Thelia/Model/om/BaseContentAssocQuery.php | 879 --- .../lib/Thelia/Model/om/BaseContentFolder.php | 1228 --- .../Thelia/Model/om/BaseContentFolderPeer.php | 1400 ---- .../Model/om/BaseContentFolderQuery.php | 660 -- core/lib/Thelia/Model/om/BaseContentI18n.php | 1187 --- .../Thelia/Model/om/BaseContentI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseContentI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseContentPeer.php | 875 --- core/lib/Thelia/Model/om/BaseContentQuery.php | 1292 ---- .../Thelia/Model/om/BaseContentVersion.php | 1395 ---- .../Model/om/BaseContentVersionPeer.php | 1026 --- .../Model/om/BaseContentVersionQuery.php | 684 -- core/lib/Thelia/Model/om/BaseCountry.php | 2142 ------ core/lib/Thelia/Model/om/BaseCountryI18n.php | 1187 --- .../Thelia/Model/om/BaseCountryI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseCountryI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseCountryPeer.php | 1050 --- core/lib/Thelia/Model/om/BaseCountryQuery.php | 889 --- core/lib/Thelia/Model/om/BaseCoupon.php | 1736 ----- core/lib/Thelia/Model/om/BaseCouponOrder.php | 1255 ---- .../Thelia/Model/om/BaseCouponOrderPeer.php | 1034 --- .../Thelia/Model/om/BaseCouponOrderQuery.php | 654 -- core/lib/Thelia/Model/om/BaseCouponPeer.php | 819 -- core/lib/Thelia/Model/om/BaseCouponQuery.php | 823 -- core/lib/Thelia/Model/om/BaseCouponRule.php | 1310 ---- .../Thelia/Model/om/BaseCouponRulePeer.php | 1039 --- .../Thelia/Model/om/BaseCouponRuleQuery.php | 687 -- core/lib/Thelia/Model/om/BaseCurrency.php | 1663 ----- core/lib/Thelia/Model/om/BaseCurrencyPeer.php | 809 -- .../lib/Thelia/Model/om/BaseCurrencyQuery.php | 716 -- core/lib/Thelia/Model/om/BaseCustomer.php | 2945 -------- core/lib/Thelia/Model/om/BaseCustomerPeer.php | 1132 --- .../lib/Thelia/Model/om/BaseCustomerQuery.php | 1432 ---- .../lib/Thelia/Model/om/BaseCustomerTitle.php | 2180 ------ .../Thelia/Model/om/BaseCustomerTitleI18n.php | 1077 --- .../Model/om/BaseCustomerTitleI18nPeer.php | 1006 --- .../Model/om/BaseCustomerTitleI18nQuery.php | 471 -- .../Thelia/Model/om/BaseCustomerTitlePeer.php | 805 -- .../Model/om/BaseCustomerTitleQuery.php | 819 -- core/lib/Thelia/Model/om/BaseDelivzone.php | 1200 --- .../lib/Thelia/Model/om/BaseDelivzonePeer.php | 1029 --- .../Thelia/Model/om/BaseDelivzoneQuery.php | 608 -- core/lib/Thelia/Model/om/BaseDocument.php | 2193 ------ core/lib/Thelia/Model/om/BaseDocumentI18n.php | 1187 --- .../Thelia/Model/om/BaseDocumentI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseDocumentI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseDocumentPeer.php | 2200 ------ .../lib/Thelia/Model/om/BaseDocumentQuery.php | 1177 --- core/lib/Thelia/Model/om/BaseFeature.php | 2782 ------- core/lib/Thelia/Model/om/BaseFeatureAv.php | 1988 ----- .../lib/Thelia/Model/om/BaseFeatureAvI18n.php | 1187 --- .../Thelia/Model/om/BaseFeatureAvI18nPeer.php | 1016 --- .../Model/om/BaseFeatureAvI18nQuery.php | 537 -- .../lib/Thelia/Model/om/BaseFeatureAvPeer.php | 1039 --- .../Thelia/Model/om/BaseFeatureAvQuery.php | 790 -- .../Thelia/Model/om/BaseFeatureCategory.php | 1287 ---- .../Model/om/BaseFeatureCategoryPeer.php | 1423 ---- .../Model/om/BaseFeatureCategoryQuery.php | 704 -- core/lib/Thelia/Model/om/BaseFeatureI18n.php | 1187 --- .../Thelia/Model/om/BaseFeatureI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseFeatureI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseFeaturePeer.php | 813 -- core/lib/Thelia/Model/om/BaseFeatureProd.php | 1539 ---- .../Thelia/Model/om/BaseFeatureProdPeer.php | 1785 ----- .../Thelia/Model/om/BaseFeatureProdQuery.php | 912 --- core/lib/Thelia/Model/om/BaseFeatureQuery.php | 929 --- core/lib/Thelia/Model/om/BaseFolder.php | 4141 ---------- core/lib/Thelia/Model/om/BaseFolderI18n.php | 1187 --- .../Thelia/Model/om/BaseFolderI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseFolderI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseFolderPeer.php | 881 --- core/lib/Thelia/Model/om/BaseFolderQuery.php | 1292 ---- .../lib/Thelia/Model/om/BaseFolderVersion.php | 1505 ---- .../Thelia/Model/om/BaseFolderVersionPeer.php | 1036 --- .../Model/om/BaseFolderVersionQuery.php | 763 -- core/lib/Thelia/Model/om/BaseGroup.php | 2926 -------- core/lib/Thelia/Model/om/BaseGroupI18n.php | 1187 --- .../lib/Thelia/Model/om/BaseGroupI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseGroupI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseGroupModule.php | 1369 ---- .../Thelia/Model/om/BaseGroupModulePeer.php | 1428 ---- .../Thelia/Model/om/BaseGroupModuleQuery.php | 750 -- core/lib/Thelia/Model/om/BaseGroupPeer.php | 808 -- core/lib/Thelia/Model/om/BaseGroupQuery.php | 888 --- .../lib/Thelia/Model/om/BaseGroupResource.php | 1440 ---- .../Thelia/Model/om/BaseGroupResourcePeer.php | 1430 ---- .../Model/om/BaseGroupResourceQuery.php | 803 -- core/lib/Thelia/Model/om/BaseImage.php | 2193 ------ core/lib/Thelia/Model/om/BaseImageI18n.php | 1187 --- .../lib/Thelia/Model/om/BaseImageI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseImageI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseImagePeer.php | 2200 ------ core/lib/Thelia/Model/om/BaseImageQuery.php | 1177 --- core/lib/Thelia/Model/om/BaseLang.php | 1252 ---- core/lib/Thelia/Model/om/BaseLangPeer.php | 805 -- core/lib/Thelia/Model/om/BaseLangQuery.php | 622 -- core/lib/Thelia/Model/om/BaseMessage.php | 2461 ------ core/lib/Thelia/Model/om/BaseMessageI18n.php | 1132 --- .../Thelia/Model/om/BaseMessageI18nPeer.php | 1011 --- .../Thelia/Model/om/BaseMessageI18nQuery.php | 504 -- core/lib/Thelia/Model/om/BaseMessagePeer.php | 860 --- core/lib/Thelia/Model/om/BaseMessageQuery.php | 899 --- .../Thelia/Model/om/BaseMessageVersion.php | 1450 ---- .../Model/om/BaseMessageVersionPeer.php | 1031 --- .../Model/om/BaseMessageVersionQuery.php | 704 -- core/lib/Thelia/Model/om/BaseModule.php | 2030 ----- core/lib/Thelia/Model/om/BaseModuleI18n.php | 1187 --- .../Thelia/Model/om/BaseModuleI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseModuleI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseModulePeer.php | 815 -- core/lib/Thelia/Model/om/BaseModuleQuery.php | 832 --- core/lib/Thelia/Model/om/BaseOrder.php | 2868 ------- core/lib/Thelia/Model/om/BaseOrderAddress.php | 2322 ------ .../Thelia/Model/om/BaseOrderAddressPeer.php | 842 --- .../Thelia/Model/om/BaseOrderAddressQuery.php | 992 --- core/lib/Thelia/Model/om/BaseOrderFeature.php | 1255 ---- .../Thelia/Model/om/BaseOrderFeaturePeer.php | 1034 --- .../Thelia/Model/om/BaseOrderFeatureQuery.php | 641 -- core/lib/Thelia/Model/om/BaseOrderPeer.php | 2640 ------- core/lib/Thelia/Model/om/BaseOrderProduct.php | 1880 ----- .../Thelia/Model/om/BaseOrderProductPeer.php | 1068 --- .../Thelia/Model/om/BaseOrderProductQuery.php | 970 --- core/lib/Thelia/Model/om/BaseOrderQuery.php | 1618 ---- core/lib/Thelia/Model/om/BaseOrderStatus.php | 1940 ----- .../Thelia/Model/om/BaseOrderStatusI18n.php | 1187 --- .../Model/om/BaseOrderStatusI18nPeer.php | 1016 --- .../Model/om/BaseOrderStatusI18nQuery.php | 537 -- .../Thelia/Model/om/BaseOrderStatusPeer.php | 800 -- .../Thelia/Model/om/BaseOrderStatusQuery.php | 694 -- core/lib/Thelia/Model/om/BaseProduct.php | 6634 ----------------- .../Thelia/Model/om/BaseProductCategory.php | 1228 --- .../Model/om/BaseProductCategoryPeer.php | 1400 ---- .../Model/om/BaseProductCategoryQuery.php | 660 -- core/lib/Thelia/Model/om/BaseProductI18n.php | 1187 --- .../Thelia/Model/om/BaseProductI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseProductI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseProductPeer.php | 1174 --- core/lib/Thelia/Model/om/BaseProductQuery.php | 2125 ------ .../Thelia/Model/om/BaseProductVersion.php | 1914 ----- .../Model/om/BaseProductVersionPeer.php | 1071 --- .../Model/om/BaseProductVersionQuery.php | 1085 --- core/lib/Thelia/Model/om/BaseResource.php | 2090 ------ core/lib/Thelia/Model/om/BaseResourceI18n.php | 1187 --- .../Thelia/Model/om/BaseResourceI18nPeer.php | 1016 --- .../Thelia/Model/om/BaseResourceI18nQuery.php | 537 -- core/lib/Thelia/Model/om/BaseResourcePeer.php | 800 -- .../lib/Thelia/Model/om/BaseResourceQuery.php | 712 -- core/lib/Thelia/Model/om/BaseRewriting.php | 1615 ---- .../lib/Thelia/Model/om/BaseRewritingPeer.php | 2180 ------ .../Thelia/Model/om/BaseRewritingQuery.php | 995 --- core/lib/Thelia/Model/om/BaseStock.php | 1397 ---- core/lib/Thelia/Model/om/BaseStockPeer.php | 1433 ---- core/lib/Thelia/Model/om/BaseStockQuery.php | 796 -- core/lib/Thelia/Model/om/BaseTax.php | 1842 ----- core/lib/Thelia/Model/om/BaseTaxI18n.php | 1077 --- core/lib/Thelia/Model/om/BaseTaxI18nPeer.php | 1006 --- core/lib/Thelia/Model/om/BaseTaxI18nQuery.php | 471 -- core/lib/Thelia/Model/om/BaseTaxPeer.php | 800 -- core/lib/Thelia/Model/om/BaseTaxQuery.php | 707 -- core/lib/Thelia/Model/om/BaseTaxRule.php | 2185 ------ .../Thelia/Model/om/BaseTaxRuleCountry.php | 1473 ---- .../Model/om/BaseTaxRuleCountryPeer.php | 1776 ----- .../Model/om/BaseTaxRuleCountryQuery.php | 879 --- core/lib/Thelia/Model/om/BaseTaxRuleI18n.php | 967 --- .../Thelia/Model/om/BaseTaxRuleI18nPeer.php | 996 --- .../Thelia/Model/om/BaseTaxRuleI18nQuery.php | 405 - core/lib/Thelia/Model/om/BaseTaxRulePeer.php | 814 -- core/lib/Thelia/Model/om/BaseTaxRuleQuery.php | 839 --- templates/smarty-sample/index.html | 30 +- 531 files changed, 516 insertions(+), 287452 deletions(-) mode change 100755 => 100644 core/lib/Thelia/Model/Accessory.php delete mode 100755 core/lib/Thelia/Model/AccessoryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AccessoryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Address.php delete mode 100755 core/lib/Thelia/Model/AddressPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AddressQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Admin.php mode change 100755 => 100644 core/lib/Thelia/Model/AdminGroup.php delete mode 100755 core/lib/Thelia/Model/AdminGroupPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AdminGroupQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/AdminLog.php delete mode 100755 core/lib/Thelia/Model/AdminLogPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AdminLogQuery.php delete mode 100755 core/lib/Thelia/Model/AdminPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AdminQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Area.php delete mode 100755 core/lib/Thelia/Model/AreaPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AreaQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Attribute.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeAv.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeAvI18n.php delete mode 100755 core/lib/Thelia/Model/AttributeAvI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeAvI18nQuery.php delete mode 100755 core/lib/Thelia/Model/AttributeAvPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeAvQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeCategory.php delete mode 100755 core/lib/Thelia/Model/AttributeCategoryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeCategoryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeCombination.php delete mode 100755 core/lib/Thelia/Model/AttributeCombinationPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeCombinationQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeI18n.php delete mode 100755 core/lib/Thelia/Model/AttributeI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeI18nQuery.php delete mode 100755 core/lib/Thelia/Model/AttributePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/AttributeQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Category.php mode change 100755 => 100644 core/lib/Thelia/Model/CategoryI18n.php delete mode 100755 core/lib/Thelia/Model/CategoryI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CategoryI18nQuery.php delete mode 100755 core/lib/Thelia/Model/CategoryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CategoryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/CategoryVersion.php delete mode 100755 core/lib/Thelia/Model/CategoryVersionPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CategoryVersionQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Combination.php delete mode 100755 core/lib/Thelia/Model/CombinationPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CombinationQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Config.php mode change 100755 => 100644 core/lib/Thelia/Model/ConfigI18n.php delete mode 100755 core/lib/Thelia/Model/ConfigI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ConfigI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ConfigPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ConfigQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Content.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentAssoc.php delete mode 100755 core/lib/Thelia/Model/ContentAssocPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentAssocQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentFolder.php delete mode 100755 core/lib/Thelia/Model/ContentFolderPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentFolderQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentI18n.php delete mode 100755 core/lib/Thelia/Model/ContentI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ContentPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentVersion.php delete mode 100755 core/lib/Thelia/Model/ContentVersionPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ContentVersionQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Country.php mode change 100755 => 100644 core/lib/Thelia/Model/CountryI18n.php delete mode 100755 core/lib/Thelia/Model/CountryI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CountryI18nQuery.php delete mode 100755 core/lib/Thelia/Model/CountryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CountryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Coupon.php mode change 100755 => 100644 core/lib/Thelia/Model/CouponOrder.php delete mode 100755 core/lib/Thelia/Model/CouponOrderPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CouponOrderQuery.php delete mode 100755 core/lib/Thelia/Model/CouponPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CouponQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/CouponRule.php delete mode 100755 core/lib/Thelia/Model/CouponRulePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CouponRuleQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Currency.php delete mode 100755 core/lib/Thelia/Model/CurrencyPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CurrencyQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Customer.php delete mode 100755 core/lib/Thelia/Model/CustomerPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CustomerQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/CustomerTitle.php mode change 100755 => 100644 core/lib/Thelia/Model/CustomerTitleI18n.php delete mode 100755 core/lib/Thelia/Model/CustomerTitleI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CustomerTitleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/CustomerTitlePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/CustomerTitleQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Delivzone.php delete mode 100755 core/lib/Thelia/Model/DelivzonePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/DelivzoneQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Document.php mode change 100755 => 100644 core/lib/Thelia/Model/DocumentI18n.php delete mode 100755 core/lib/Thelia/Model/DocumentI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/DocumentI18nQuery.php delete mode 100755 core/lib/Thelia/Model/DocumentPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/DocumentQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Feature.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureAv.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureAvI18n.php delete mode 100755 core/lib/Thelia/Model/FeatureAvI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureAvI18nQuery.php delete mode 100755 core/lib/Thelia/Model/FeatureAvPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureAvQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureCategory.php delete mode 100755 core/lib/Thelia/Model/FeatureCategoryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureCategoryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureI18n.php delete mode 100755 core/lib/Thelia/Model/FeatureI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureI18nQuery.php delete mode 100755 core/lib/Thelia/Model/FeaturePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureProd.php delete mode 100755 core/lib/Thelia/Model/FeatureProdPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureProdQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/FeatureQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Folder.php mode change 100755 => 100644 core/lib/Thelia/Model/FolderI18n.php delete mode 100755 core/lib/Thelia/Model/FolderI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FolderI18nQuery.php delete mode 100755 core/lib/Thelia/Model/FolderPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FolderQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/FolderVersion.php delete mode 100755 core/lib/Thelia/Model/FolderVersionPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/FolderVersionQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Group.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupI18n.php delete mode 100755 core/lib/Thelia/Model/GroupI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupI18nQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupModule.php delete mode 100755 core/lib/Thelia/Model/GroupModulePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupModuleQuery.php delete mode 100755 core/lib/Thelia/Model/GroupPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupResource.php delete mode 100755 core/lib/Thelia/Model/GroupResourcePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/GroupResourceQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Image.php mode change 100755 => 100644 core/lib/Thelia/Model/ImageI18n.php delete mode 100755 core/lib/Thelia/Model/ImageI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ImageI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ImagePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ImageQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Lang.php delete mode 100755 core/lib/Thelia/Model/LangPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/LangQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Message.php mode change 100755 => 100644 core/lib/Thelia/Model/MessageI18n.php delete mode 100755 core/lib/Thelia/Model/MessageI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/MessageI18nQuery.php delete mode 100755 core/lib/Thelia/Model/MessagePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/MessageQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/MessageVersion.php delete mode 100755 core/lib/Thelia/Model/MessageVersionPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/MessageVersionQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Module.php mode change 100755 => 100644 core/lib/Thelia/Model/ModuleI18n.php delete mode 100755 core/lib/Thelia/Model/ModuleI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ModuleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ModulePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ModuleQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Order.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderAddress.php delete mode 100755 core/lib/Thelia/Model/OrderAddressPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderAddressQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderFeature.php delete mode 100755 core/lib/Thelia/Model/OrderFeaturePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderFeatureQuery.php delete mode 100755 core/lib/Thelia/Model/OrderPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderProduct.php delete mode 100755 core/lib/Thelia/Model/OrderProductPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderProductQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderStatus.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderStatusI18n.php delete mode 100755 core/lib/Thelia/Model/OrderStatusI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderStatusI18nQuery.php delete mode 100755 core/lib/Thelia/Model/OrderStatusPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/OrderStatusQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Product.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductCategory.php delete mode 100755 core/lib/Thelia/Model/ProductCategoryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductCategoryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductI18n.php delete mode 100755 core/lib/Thelia/Model/ProductI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ProductPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductVersion.php delete mode 100755 core/lib/Thelia/Model/ProductVersionPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ProductVersionQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Resource.php mode change 100755 => 100644 core/lib/Thelia/Model/ResourceI18n.php delete mode 100755 core/lib/Thelia/Model/ResourceI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ResourceI18nQuery.php delete mode 100755 core/lib/Thelia/Model/ResourcePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/ResourceQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Rewriting.php delete mode 100755 core/lib/Thelia/Model/RewritingPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/RewritingQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Stock.php delete mode 100755 core/lib/Thelia/Model/StockPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/StockQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/Tax.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxI18n.php delete mode 100755 core/lib/Thelia/Model/TaxI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxI18nQuery.php delete mode 100755 core/lib/Thelia/Model/TaxPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRule.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRuleCountry.php delete mode 100755 core/lib/Thelia/Model/TaxRuleCountryPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRuleCountryQuery.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRuleI18n.php delete mode 100755 core/lib/Thelia/Model/TaxRuleI18nPeer.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRuleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/TaxRulePeer.php mode change 100755 => 100644 core/lib/Thelia/Model/TaxRuleQuery.php delete mode 100755 core/lib/Thelia/Model/map/AccessoryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AddressTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AdminGroupTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AdminLogTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AdminTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AreaTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeAvTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeCategoryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeCombinationTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/AttributeTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CategoryI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CategoryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CategoryVersionTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CombinationTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ConfigI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ConfigTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ContentAssocTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ContentFolderTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ContentI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ContentTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ContentVersionTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CountryI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CountryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CouponOrderTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CouponRuleTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CouponTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CurrencyTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CustomerTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/CustomerTitleTableMap.php delete mode 100755 core/lib/Thelia/Model/map/DelivzoneTableMap.php delete mode 100755 core/lib/Thelia/Model/map/DocumentI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/DocumentTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureAvTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureCategoryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureProdTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FeatureTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FolderI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FolderTableMap.php delete mode 100755 core/lib/Thelia/Model/map/FolderVersionTableMap.php delete mode 100755 core/lib/Thelia/Model/map/GroupI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/GroupModuleTableMap.php delete mode 100755 core/lib/Thelia/Model/map/GroupResourceTableMap.php delete mode 100755 core/lib/Thelia/Model/map/GroupTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ImageI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ImageTableMap.php delete mode 100755 core/lib/Thelia/Model/map/LangTableMap.php delete mode 100755 core/lib/Thelia/Model/map/MessageI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/MessageTableMap.php delete mode 100755 core/lib/Thelia/Model/map/MessageVersionTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ModuleI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ModuleTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderAddressTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderFeatureTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderProductTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderStatusTableMap.php delete mode 100755 core/lib/Thelia/Model/map/OrderTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ProductCategoryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ProductI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ProductTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ProductVersionTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ResourceI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/ResourceTableMap.php delete mode 100755 core/lib/Thelia/Model/map/RewritingTableMap.php delete mode 100755 core/lib/Thelia/Model/map/StockTableMap.php delete mode 100755 core/lib/Thelia/Model/map/TaxI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php delete mode 100755 core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php delete mode 100755 core/lib/Thelia/Model/map/TaxRuleTableMap.php delete mode 100755 core/lib/Thelia/Model/map/TaxTableMap.php delete mode 100755 core/lib/Thelia/Model/om/BaseAccessory.php delete mode 100755 core/lib/Thelia/Model/om/BaseAccessoryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAccessoryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAddress.php delete mode 100755 core/lib/Thelia/Model/om/BaseAddressPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAddressQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdmin.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminGroup.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminGroupPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminGroupQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminLog.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminLogPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminLogQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAdminQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseArea.php delete mode 100755 core/lib/Thelia/Model/om/BaseAreaPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAreaQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttribute.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAv.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAvI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAvPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeAvQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCategory.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCombination.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseAttributeQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategory.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryVersion.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCombination.php delete mode 100755 core/lib/Thelia/Model/om/BaseCombinationPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCombinationQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfig.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfigI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfigI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfigI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfigPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseConfigQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseContent.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentAssoc.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentAssocPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentAssocQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentFolder.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentFolderPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentFolderQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentVersion.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentVersionPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseContentVersionQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountry.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountryI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountryI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountryI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCountryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCoupon.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponOrder.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponOrderPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponOrderQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponRule.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponRulePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCouponRuleQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCurrency.php delete mode 100755 core/lib/Thelia/Model/om/BaseCurrencyPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCurrencyQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitle.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseDelivzone.php delete mode 100755 core/lib/Thelia/Model/om/BaseDelivzonePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseDelivzoneQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocument.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocumentI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocumentPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseDocumentQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeature.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAv.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAvI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAvPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureAvQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureCategory.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeaturePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureProd.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureProdPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureProdQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFeatureQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolder.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderVersion.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderVersionPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseFolderVersionQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroup.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupModule.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupModulePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupModuleQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupResource.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupResourcePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseGroupResourceQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseImage.php delete mode 100755 core/lib/Thelia/Model/om/BaseImageI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseImageI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseImageI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseImagePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseImageQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseLang.php delete mode 100755 core/lib/Thelia/Model/om/BaseLangPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseLangQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessage.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessagePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageVersion.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageVersionPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseMessageVersionQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseModule.php delete mode 100755 core/lib/Thelia/Model/om/BaseModuleI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseModuleI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseModuleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseModulePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseModuleQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrder.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderAddress.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderAddressPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderAddressQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderFeature.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderProduct.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderProductPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderProductQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatus.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatusI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatusPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseOrderStatusQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseProduct.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductCategory.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductCategoryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductCategoryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductVersion.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductVersionPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseProductVersionQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseResource.php delete mode 100755 core/lib/Thelia/Model/om/BaseResourceI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseResourceI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseResourceI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseResourcePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseResourceQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseRewriting.php delete mode 100755 core/lib/Thelia/Model/om/BaseRewritingPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseRewritingQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseStock.php delete mode 100755 core/lib/Thelia/Model/om/BaseStockPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseStockQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseTax.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRule.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleCountry.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleI18n.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRulePeer.php delete mode 100755 core/lib/Thelia/Model/om/BaseTaxRuleQuery.php diff --git a/composer.json b/composer.json index 9cc776517..af9b1709b 100755 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "php": ">=5.3", "ezyang/htmlpurifier": "dev-master", "ircmaxell/password-compat": "dev-master", - "propel/propel1" : "1.6.*", + "propel/propel": "2.0.0-alpha1", "psr/log" : "1.0", "symfony/class-loader": "2.2.*", "symfony/config" : "2.2.*", diff --git a/core/lib/Thelia/Config/DefinePropel.php b/core/lib/Thelia/Config/DefinePropel.php index 800fa53ac..802fa49c3 100755 --- a/core/lib/Thelia/Config/DefinePropel.php +++ b/core/lib/Thelia/Config/DefinePropel.php @@ -41,20 +41,10 @@ class DefinePropel { { $connection = $this->processorConfig["connection"]; return $conf = array( - "datasources" => - array( - "thelia" => - array( - "adapter" => $connection["driver"], - "connection" => - array( - "dsn" => $connection["dsn"], - "user" => $connection["user"], - "password" => $connection["password"], - "classname" => $connection["classname"] - ) - ) - ) + "dsn" => $connection["dsn"], + "user" => $connection["user"], + "password" => $connection["password"], + //"classname" => $connection["classname"] ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 6863f1a09..c2399a3d3 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -26,6 +26,7 @@ namespace Thelia\Core\Template\Element; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Template\Loop\Argument\Argument; +use Propel\Runtime\ActiveQuery\ModelCriteria; /** * @@ -78,7 +79,7 @@ abstract class BaseLoop * * @return array|mixed|\PropelModelPager|\PropelObjectCollection */ - public function search(\ModelCriteria $search, &$pagination = null) + public function search(ModelCriteria $search, &$pagination = null) { if($this->page !== null) { return $this->searchWithPagination($search, $pagination); @@ -92,7 +93,7 @@ abstract class BaseLoop * * @return array|mixed|\PropelObjectCollection */ - public function searchWithOffset(\ModelCriteria $search) + public function searchWithOffset(ModelCriteria $search) { if($this->limit >= 0) { $search->limit($this->limit); @@ -108,7 +109,7 @@ abstract class BaseLoop * * @return array|\PropelModelPager */ - public function searchWithPagination(\ModelCriteria $search, &$pagination) + public function searchWithPagination(ModelCriteria $search, &$pagination) { $pagination = $search->paginate($this->page, $this->limit); diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 55be4d69a..25c0b5bd7 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -23,6 +23,7 @@ namespace Thelia\Core\Template\Loop; +use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; @@ -108,7 +109,7 @@ class Category extends BaseLoop $search = CategoryQuery::create(); if (!is_null($this->id)) { - $search->filterById(explode(',', $this->id), \Criteria::IN); + $search->filterById(explode(',', $this->id), ModelCriteria::IN); } if (!is_null($this->parent)) { @@ -118,11 +119,11 @@ class Category extends BaseLoop if ($this->current == 1) { $search->filterById($this->request->get("category_id")); } elseif (null !== $this->current && $this->current == 0) { - $search->filterById($this->request->get("category_id"), \Criteria::NOT_IN); + $search->filterById($this->request->get("category_id"), ModelCriteria::NOT_IN); } if (!is_null($this->exclude)) { - $search->filterById(explode(",", $this->exclude), \Criteria::NOT_IN); + $search->filterById(explode(",", $this->exclude), ModelCriteria::NOT_IN); } if (!is_null($this->link)) { @@ -156,7 +157,7 @@ class Category extends BaseLoop * * @todo : verify here if we want results for row without translations. */ - $search->joinWithI18n($this->request->getSession()->get('locale', 'en_US'), \Criteria::INNER_JOIN); + $search->joinWithI18n('en_US'); $categories = $this->search($search, $pagination); diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 72a72f4f9..9e77d1d88 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -46,8 +46,8 @@ use Thelia\Core\TheliaContainerBuilder; use Thelia\Core\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\Config\FileLocator; -use Propel; -use PropelConfiguration; +use Propel\Runtime\Propel; +use Propel\Runtime\Connection\ConnectionManagerSingle; class Thelia extends Kernel { @@ -71,7 +71,7 @@ class Thelia extends Kernel return ; } - if (! Propel::isInit()) { +/* if (! Propel::isInit()) { $definePropel = new DefinePropel(new DatabaseConfiguration(), Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); @@ -97,7 +97,16 @@ class Thelia extends Kernel } Propel::initialize(); - } + }*/ + + $definePropel = new DefinePropel(new DatabaseConfiguration(), + Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); + $propelConfig = $definePropel->getConfig(); + $serviceContainer = Propel::getServiceContainer(); + $serviceContainer->setAdapterClass('thelia', 'mysql'); + $manager = new ConnectionManagerSingle(); + $manager->setConfiguration($definePropel->getConfig()); + $serviceContainer->setConnectionManager('thelia', $manager); } /** diff --git a/core/lib/Thelia/Model/Accessory.php b/core/lib/Thelia/Model/Accessory.php old mode 100755 new mode 100644 index 8c5b138ed..2e927ff7c --- a/core/lib/Thelia/Model/Accessory.php +++ b/core/lib/Thelia/Model/Accessory.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseAccessory; +use Thelia\Model\Base\Accessory as BaseAccessory; +class Accessory extends BaseAccessory { -/** - * Skeleton subclass for representing a row from the 'accessory' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package propel.generator.Thelia.Model - */ -class Accessory extends BaseAccessory -{ } diff --git a/core/lib/Thelia/Model/AccessoryPeer.php b/core/lib/Thelia/Model/AccessoryPeer.php deleted file mode 100755 index d4ba95854..000000000 --- a/core/lib/Thelia/Model/AccessoryPeer.php +++ /dev/null @@ -1,21 +0,0 @@ -findOneByName($search); return $value ? $value->getValue() : $default; } -} +} // ConfigQuery diff --git a/core/lib/Thelia/Model/Content.php b/core/lib/Thelia/Model/Content.php old mode 100755 new mode 100644 index 0c509e0e1..19b76bba2 --- a/core/lib/Thelia/Model/Content.php +++ b/core/lib/Thelia/Model/Content.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseContent; +use Thelia\Model\Base\Content as BaseContent; +class Content extends BaseContent { -/** - * Skeleton subclass for representing a row from the 'content' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package propel.generator.Thelia.Model - */ -class Content extends BaseContent -{ } diff --git a/core/lib/Thelia/Model/ContentAssoc.php b/core/lib/Thelia/Model/ContentAssoc.php old mode 100755 new mode 100644 index 4c652fb15..0723ef537 --- a/core/lib/Thelia/Model/ContentAssoc.php +++ b/core/lib/Thelia/Model/ContentAssoc.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseContentAssoc; +use Thelia\Model\Base\ContentAssoc as BaseContentAssoc; +class ContentAssoc extends BaseContentAssoc { -/** - * Skeleton subclass for representing a row from the 'content_assoc' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package propel.generator.Thelia.Model - */ -class ContentAssoc extends BaseContentAssoc -{ } diff --git a/core/lib/Thelia/Model/ContentAssocPeer.php b/core/lib/Thelia/Model/ContentAssocPeer.php deleted file mode 100755 index e33d07f59..000000000 --- a/core/lib/Thelia/Model/ContentAssocPeer.php +++ /dev/null @@ -1,21 +0,0 @@ -setCustomerTitleId($titleId) @@ -45,9 +49,14 @@ class Customer extends BaseCustomer ->setReseller($reseller) ->setSponsor($sponsor) ->setDiscount($discount) - ->save() ; + if(!is_null($lang)) { + $this->setLang($lang); + } + + $this->save(); + } public function preInsert(\PropelPDO $con = null) @@ -69,8 +78,16 @@ class Customer extends BaseCustomer public function setPassword($password) { - $this->setAlgo("PASSWORD_BCRYPT"); - return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + \Thelia\Log\Tlog::getInstance()->debug($password); + if ($this->isNew() && ($password === null || trim($password) == "")) { + throw new InvalidArgumentException("customer password is mandatory on creation"); + } + + if($password !== null && trim($password) != "") { + $this->setAlgo("PASSWORD_BCRYPT"); + return parent::setPassword(password_hash($password, PASSWORD_BCRYPT)); + } + } public function setDispatcher(EventDispatcherInterface $dispatcher) diff --git a/core/lib/Thelia/Model/CustomerPeer.php b/core/lib/Thelia/Model/CustomerPeer.php deleted file mode 100755 index e20e69139..000000000 --- a/core/lib/Thelia/Model/CustomerPeer.php +++ /dev/null @@ -1,21 +0,0 @@ -filterByActivate(1) - ->find() - ; + ->find(); } -} +} // ModuleQuery diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php old mode 100755 new mode 100644 index 3a579698d..91582750a --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseOrder; +use Thelia\Model\Base\Order as BaseOrder; +class Order extends BaseOrder { -/** - * Skeleton subclass for representing a row from the 'order' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package propel.generator.Thelia.Model - */ -class Order extends BaseOrder -{ } diff --git a/core/lib/Thelia/Model/OrderAddress.php b/core/lib/Thelia/Model/OrderAddress.php old mode 100755 new mode 100644 index 1f425f374..bb024546b --- a/core/lib/Thelia/Model/OrderAddress.php +++ b/core/lib/Thelia/Model/OrderAddress.php @@ -2,20 +2,8 @@ namespace Thelia\Model; -use Thelia\Model\om\BaseOrderAddress; +use Thelia\Model\Base\OrderAddress as BaseOrderAddress; +class OrderAddress extends BaseOrderAddress { -/** - * Skeleton subclass for representing a row from the 'order_address' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package propel.generator.Thelia.Model - */ -class OrderAddress extends BaseOrderAddress -{ } diff --git a/core/lib/Thelia/Model/OrderAddressPeer.php b/core/lib/Thelia/Model/OrderAddressPeer.php deleted file mode 100755 index 4103c9e11..000000000 --- a/core/lib/Thelia/Model/OrderAddressPeer.php +++ /dev/null @@ -1,21 +0,0 @@ -setName('accessory'); - $this->setPhpName('Accessory'); - $this->setClassname('Thelia\\Model\\Accessory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); - $this->addForeignKey('accessory', 'Accessory', 'INTEGER', 'product', 'id', true, null, null); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('ProductRelatedByProductId', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('ProductRelatedByAccessory', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('accessory' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AccessoryTableMap diff --git a/core/lib/Thelia/Model/map/AddressTableMap.php b/core/lib/Thelia/Model/map/AddressTableMap.php deleted file mode 100755 index 3005b2b89..000000000 --- a/core/lib/Thelia/Model/map/AddressTableMap.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('address'); - $this->setPhpName('Address'); - $this->setClassname('Thelia\\Model\\Address'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', true, null, null); - $this->addForeignKey('customer_title_id', 'CustomerTitleId', 'INTEGER', 'customer_title', 'id', false, null, null); - $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('address2', 'Address2', 'VARCHAR', true, 255, null); - $this->addColumn('address3', 'Address3', 'VARCHAR', true, 255, null); - $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', true, 10, null); - $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'RESTRICT', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AddressTableMap diff --git a/core/lib/Thelia/Model/map/AdminGroupTableMap.php b/core/lib/Thelia/Model/map/AdminGroupTableMap.php deleted file mode 100755 index 3304ac244..000000000 --- a/core/lib/Thelia/Model/map/AdminGroupTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('admin_group'); - $this->setPhpName('AdminGroup'); - $this->setClassname('Thelia\\Model\\AdminGroup'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('group_id', 'GroupId', 'INTEGER' , 'group', 'id', true, null, null); - $this->addForeignPrimaryKey('admin_id', 'AdminId', 'INTEGER' , 'admin', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AdminGroupTableMap diff --git a/core/lib/Thelia/Model/map/AdminLogTableMap.php b/core/lib/Thelia/Model/map/AdminLogTableMap.php deleted file mode 100755 index 4c4698279..000000000 --- a/core/lib/Thelia/Model/map/AdminLogTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('admin_log'); - $this->setPhpName('AdminLog'); - $this->setClassname('Thelia\\Model\\AdminLog'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('admin_login', 'AdminLogin', 'VARCHAR', false, 255, null); - $this->addColumn('admin_firstname', 'AdminFirstname', 'VARCHAR', false, 255, null); - $this->addColumn('admin_lastname', 'AdminLastname', 'VARCHAR', false, 255, null); - $this->addColumn('action', 'Action', 'VARCHAR', false, 255, null); - $this->addColumn('request', 'Request', 'LONGVARCHAR', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AdminLogTableMap diff --git a/core/lib/Thelia/Model/map/AdminTableMap.php b/core/lib/Thelia/Model/map/AdminTableMap.php deleted file mode 100755 index 0ba007494..000000000 --- a/core/lib/Thelia/Model/map/AdminTableMap.php +++ /dev/null @@ -1,83 +0,0 @@ -setName('admin'); - $this->setPhpName('Admin'); - $this->setClassname('Thelia\\Model\\Admin'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 100, null); - $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 100, null); - $this->addColumn('login', 'Login', 'VARCHAR', true, 100, null); - $this->addColumn('password', 'Password', 'VARCHAR', true, 128, null); - $this->addColumn('algo', 'Algo', 'VARCHAR', false, 128, null); - $this->addColumn('salt', 'Salt', 'VARCHAR', false, 128, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AdminTableMap diff --git a/core/lib/Thelia/Model/map/AreaTableMap.php b/core/lib/Thelia/Model/map/AreaTableMap.php deleted file mode 100755 index 5fffa8cab..000000000 --- a/core/lib/Thelia/Model/map/AreaTableMap.php +++ /dev/null @@ -1,79 +0,0 @@ -setName('area'); - $this->setPhpName('Area'); - $this->setClassname('Thelia\\Model\\Area'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('name', 'Name', 'VARCHAR', true, 100, null); - $this->addColumn('unit', 'Unit', 'FLOAT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Countrys'); - $this->addRelation('Delivzone', 'Thelia\\Model\\Delivzone', RelationMap::ONE_TO_MANY, array('id' => 'area_id', ), 'SET NULL', 'RESTRICT', 'Delivzones'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AreaTableMap diff --git a/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php deleted file mode 100755 index 449d28112..000000000 --- a/core/lib/Thelia/Model/map/AttributeAvI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('attribute_av_i18n'); - $this->setPhpName('AttributeAvI18n'); - $this->setClassname('Thelia\\Model\\AttributeAvI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'attribute_av', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // AttributeAvI18nTableMap diff --git a/core/lib/Thelia/Model/map/AttributeAvTableMap.php b/core/lib/Thelia/Model/map/AttributeAvTableMap.php deleted file mode 100755 index 9938cf156..000000000 --- a/core/lib/Thelia/Model/map/AttributeAvTableMap.php +++ /dev/null @@ -1,89 +0,0 @@ -setName('attribute_av'); - $this->setPhpName('AttributeAv'); - $this->setClassname('Thelia\\Model\\AttributeAv'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('attribute_id', 'AttributeId', 'INTEGER', 'attribute', 'id', true, null, null); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_av_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); - $this->addRelation('AttributeAvI18n', 'Thelia\\Model\\AttributeAvI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'AttributeAvI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // AttributeAvTableMap diff --git a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php b/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php deleted file mode 100755 index 3d21de5f7..000000000 --- a/core/lib/Thelia/Model/map/AttributeCategoryTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('attribute_category'); - $this->setPhpName('AttributeCategory'); - $this->setClassname('Thelia\\Model\\AttributeCategory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', true, null, null); - $this->addForeignKey('attribute_id', 'AttributeId', 'INTEGER', 'attribute', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AttributeCategoryTableMap diff --git a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php b/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php deleted file mode 100755 index 2a6b1c570..000000000 --- a/core/lib/Thelia/Model/map/AttributeCombinationTableMap.php +++ /dev/null @@ -1,81 +0,0 @@ -setName('attribute_combination'); - $this->setPhpName('AttributeCombination'); - $this->setClassname('Thelia\\Model\\AttributeCombination'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('attribute_id', 'AttributeId', 'INTEGER' , 'attribute', 'id', true, null, null); - $this->addForeignPrimaryKey('combination_id', 'CombinationId', 'INTEGER' , 'combination', 'id', true, null, null); - $this->addForeignPrimaryKey('attribute_av_id', 'AttributeAvId', 'INTEGER' , 'attribute_av', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('attribute_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::MANY_TO_ONE, array('attribute_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // AttributeCombinationTableMap diff --git a/core/lib/Thelia/Model/map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/map/AttributeI18nTableMap.php deleted file mode 100755 index 41b40bf43..000000000 --- a/core/lib/Thelia/Model/map/AttributeI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('attribute_i18n'); - $this->setPhpName('AttributeI18n'); - $this->setClassname('Thelia\\Model\\AttributeI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'attribute', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // AttributeI18nTableMap diff --git a/core/lib/Thelia/Model/map/AttributeTableMap.php b/core/lib/Thelia/Model/map/AttributeTableMap.php deleted file mode 100755 index edd977a3f..000000000 --- a/core/lib/Thelia/Model/map/AttributeTableMap.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('attribute'); - $this->setPhpName('Attribute'); - $this->setClassname('Thelia\\Model\\Attribute'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AttributeAv', 'Thelia\\Model\\AttributeAv', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeAvs'); - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); - $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'attribute_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategorys'); - $this->addRelation('AttributeI18n', 'Thelia\\Model\\AttributeI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'AttributeI18ns'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categorys'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // AttributeTableMap diff --git a/core/lib/Thelia/Model/map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/map/CategoryI18nTableMap.php deleted file mode 100755 index 9e6d287cf..000000000 --- a/core/lib/Thelia/Model/map/CategoryI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('category_i18n'); - $this->setPhpName('CategoryI18n'); - $this->setClassname('Thelia\\Model\\CategoryI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'category', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * 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() - -} // CategoryI18nTableMap diff --git a/core/lib/Thelia/Model/map/CategoryTableMap.php b/core/lib/Thelia/Model/map/CategoryTableMap.php deleted file mode 100755 index 3f2f93bcd..000000000 --- a/core/lib/Thelia/Model/map/CategoryTableMap.php +++ /dev/null @@ -1,113 +0,0 @@ -setName('category'); - $this->setPhpName('Category'); - $this->setClassname('Thelia\\Model\\Category'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('parent', 'Parent', 'INTEGER', false, null, null); - $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('visible', 'Visible', 'TINYINT', true, null, null); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', 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() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ProductCategorys'); - $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategorys'); - $this->addRelation('AttributeCategory', 'Thelia\\Model\\AttributeCategory', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'AttributeCategorys'); - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Documents'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'category_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); - $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'); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Products'); - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Features'); - $this->addRelation('Attribute', 'Thelia\\Model\\Attribute', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Attributes'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - 'versionable' => array ( - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'true', - 'log_created_by' => 'true', - 'log_comment' => 'false', - 'version_created_at_column' => 'version_created_at', - 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', -), - ); - } // getBehaviors() - -} // CategoryTableMap diff --git a/core/lib/Thelia/Model/map/CategoryVersionTableMap.php b/core/lib/Thelia/Model/map/CategoryVersionTableMap.php deleted file mode 100755 index 9dbe0497e..000000000 --- a/core/lib/Thelia/Model/map/CategoryVersionTableMap.php +++ /dev/null @@ -1,66 +0,0 @@ -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/CombinationTableMap.php b/core/lib/Thelia/Model/map/CombinationTableMap.php deleted file mode 100755 index 8e14e8cf5..000000000 --- a/core/lib/Thelia/Model/map/CombinationTableMap.php +++ /dev/null @@ -1,78 +0,0 @@ -setName('combination'); - $this->setPhpName('Combination'); - $this->setClassname('Thelia\\Model\\Combination'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('ref', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AttributeCombination', 'Thelia\\Model\\AttributeCombination', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'CASCADE', 'RESTRICT', 'AttributeCombinations'); - $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'combination_id', ), 'SET NULL', 'RESTRICT', 'Stocks'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CombinationTableMap diff --git a/core/lib/Thelia/Model/map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/map/ConfigI18nTableMap.php deleted file mode 100755 index 68e73e3c4..000000000 --- a/core/lib/Thelia/Model/map/ConfigI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('config_i18n'); - $this->setPhpName('ConfigI18n'); - $this->setClassname('Thelia\\Model\\ConfigI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'config', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Config', 'Thelia\\Model\\Config', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // ConfigI18nTableMap diff --git a/core/lib/Thelia/Model/map/ConfigTableMap.php b/core/lib/Thelia/Model/map/ConfigTableMap.php deleted file mode 100755 index 33e45c37b..000000000 --- a/core/lib/Thelia/Model/map/ConfigTableMap.php +++ /dev/null @@ -1,89 +0,0 @@ -setName('config'); - $this->setPhpName('Config'); - $this->setClassname('Thelia\\Model\\Config'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); - $this->addColumn('value', 'Value', 'VARCHAR', true, 255, null); - $this->addColumn('secured', 'Secured', 'TINYINT', true, null, 1); - $this->addColumn('hidden', 'Hidden', 'TINYINT', true, null, 1); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('ConfigI18n', 'Thelia\\Model\\ConfigI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ConfigI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // ConfigTableMap diff --git a/core/lib/Thelia/Model/map/ContentAssocTableMap.php b/core/lib/Thelia/Model/map/ContentAssocTableMap.php deleted file mode 100755 index 39bea3804..000000000 --- a/core/lib/Thelia/Model/map/ContentAssocTableMap.php +++ /dev/null @@ -1,82 +0,0 @@ -setName('content_assoc'); - $this->setPhpName('ContentAssoc'); - $this->setClassname('Thelia\\Model\\ContentAssoc'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); - $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // ContentAssocTableMap diff --git a/core/lib/Thelia/Model/map/ContentFolderTableMap.php b/core/lib/Thelia/Model/map/ContentFolderTableMap.php deleted file mode 100755 index 00d702e1d..000000000 --- a/core/lib/Thelia/Model/map/ContentFolderTableMap.php +++ /dev/null @@ -1,79 +0,0 @@ -setName('content_folder'); - $this->setPhpName('ContentFolder'); - $this->setClassname('Thelia\\Model\\ContentFolder'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - $this->setIsCrossRef(true); - // columns - $this->addForeignPrimaryKey('content_id', 'ContentId', 'INTEGER' , 'content', 'id', true, null, null); - $this->addForeignPrimaryKey('folder_id', 'FolderId', 'INTEGER' , 'folder', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // ContentFolderTableMap diff --git a/core/lib/Thelia/Model/map/ContentI18nTableMap.php b/core/lib/Thelia/Model/map/ContentI18nTableMap.php deleted file mode 100755 index f0e0e6562..000000000 --- a/core/lib/Thelia/Model/map/ContentI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('content_i18n'); - $this->setPhpName('ContentI18n'); - $this->setClassname('Thelia\\Model\\ContentI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'content', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * 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() - -} // ContentI18nTableMap diff --git a/core/lib/Thelia/Model/map/ContentTableMap.php b/core/lib/Thelia/Model/map/ContentTableMap.php deleted file mode 100755 index 803533d39..000000000 --- a/core/lib/Thelia/Model/map/ContentTableMap.php +++ /dev/null @@ -1,107 +0,0 @@ -setName('content'); - $this->setPhpName('Content'); - $this->setClassname('Thelia\\Model\\Content'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', 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() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Documents'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); - $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'content_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); - $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'); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Folders'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - 'versionable' => array ( - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'true', - 'log_created_by' => 'true', - 'log_comment' => 'false', - 'version_created_at_column' => 'version_created_at', - 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', -), - ); - } // getBehaviors() - -} // ContentTableMap diff --git a/core/lib/Thelia/Model/map/ContentVersionTableMap.php b/core/lib/Thelia/Model/map/ContentVersionTableMap.php deleted file mode 100755 index 0f1eabe01..000000000 --- a/core/lib/Thelia/Model/map/ContentVersionTableMap.php +++ /dev/null @@ -1,64 +0,0 @@ -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/CountryI18nTableMap.php b/core/lib/Thelia/Model/map/CountryI18nTableMap.php deleted file mode 100755 index 698d4d209..000000000 --- a/core/lib/Thelia/Model/map/CountryI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('country_i18n'); - $this->setPhpName('CountryI18n'); - $this->setClassname('Thelia\\Model\\CountryI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'country', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // CountryI18nTableMap diff --git a/core/lib/Thelia/Model/map/CountryTableMap.php b/core/lib/Thelia/Model/map/CountryTableMap.php deleted file mode 100755 index 3c4f83b7c..000000000 --- a/core/lib/Thelia/Model/map/CountryTableMap.php +++ /dev/null @@ -1,91 +0,0 @@ -setName('country'); - $this->setPhpName('Country'); - $this->setClassname('Thelia\\Model\\Country'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('area_id', 'AreaId', 'INTEGER', 'area', 'id', false, null, null); - $this->addColumn('isocode', 'Isocode', 'VARCHAR', true, 4, null); - $this->addColumn('isoalpha2', 'Isoalpha2', 'VARCHAR', false, 2, null); - $this->addColumn('isoalpha3', 'Isoalpha3', 'VARCHAR', false, 4, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'country_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountrys'); - $this->addRelation('CountryI18n', 'Thelia\\Model\\CountryI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CountryI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // CountryTableMap diff --git a/core/lib/Thelia/Model/map/CouponOrderTableMap.php b/core/lib/Thelia/Model/map/CouponOrderTableMap.php deleted file mode 100755 index 98c71d816..000000000 --- a/core/lib/Thelia/Model/map/CouponOrderTableMap.php +++ /dev/null @@ -1,79 +0,0 @@ -setName('coupon_order'); - $this->setPhpName('CouponOrder'); - $this->setClassname('Thelia\\Model\\CouponOrder'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('order_id', 'OrderId', 'INTEGER', 'order', 'id', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('value', 'Value', 'FLOAT', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CouponOrderTableMap diff --git a/core/lib/Thelia/Model/map/CouponRuleTableMap.php b/core/lib/Thelia/Model/map/CouponRuleTableMap.php deleted file mode 100755 index 3b29f1ebe..000000000 --- a/core/lib/Thelia/Model/map/CouponRuleTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('coupon_rule'); - $this->setPhpName('CouponRule'); - $this->setClassname('Thelia\\Model\\CouponRule'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('coupon_id', 'CouponId', 'INTEGER', 'coupon', 'id', true, null, null); - $this->addColumn('controller', 'Controller', 'VARCHAR', false, 255, null); - $this->addColumn('operation', 'Operation', 'VARCHAR', false, 255, null); - $this->addColumn('value', 'Value', 'FLOAT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Coupon', 'Thelia\\Model\\Coupon', RelationMap::MANY_TO_ONE, array('coupon_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CouponRuleTableMap diff --git a/core/lib/Thelia/Model/map/CouponTableMap.php b/core/lib/Thelia/Model/map/CouponTableMap.php deleted file mode 100755 index 714d824c6..000000000 --- a/core/lib/Thelia/Model/map/CouponTableMap.php +++ /dev/null @@ -1,83 +0,0 @@ -setName('coupon'); - $this->setPhpName('Coupon'); - $this->setClassname('Thelia\\Model\\Coupon'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('action', 'Action', 'VARCHAR', true, 255, null); - $this->addColumn('value', 'Value', 'FLOAT', true, null, null); - $this->addColumn('used', 'Used', 'TINYINT', false, null, null); - $this->addColumn('available_since', 'AvailableSince', 'TIMESTAMP', false, null, null); - $this->addColumn('date_limit', 'DateLimit', 'TIMESTAMP', false, null, null); - $this->addColumn('activate', 'Activate', 'TINYINT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CouponRule', 'Thelia\\Model\\CouponRule', RelationMap::ONE_TO_MANY, array('id' => 'coupon_id', ), 'CASCADE', 'RESTRICT', 'CouponRules'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CouponTableMap diff --git a/core/lib/Thelia/Model/map/CurrencyTableMap.php b/core/lib/Thelia/Model/map/CurrencyTableMap.php deleted file mode 100755 index 14f4089ae..000000000 --- a/core/lib/Thelia/Model/map/CurrencyTableMap.php +++ /dev/null @@ -1,81 +0,0 @@ -setName('currency'); - $this->setPhpName('Currency'); - $this->setClassname('Thelia\\Model\\Currency'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('name', 'Name', 'VARCHAR', false, 45, null); - $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('symbol', 'Symbol', 'VARCHAR', false, 45, null); - $this->addColumn('rate', 'Rate', 'FLOAT', false, null, null); - $this->addColumn('by_default', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'currency_id', ), 'SET NULL', 'RESTRICT', 'Orders'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CurrencyTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTableMap.php b/core/lib/Thelia/Model/map/CustomerTableMap.php deleted file mode 100755 index 8f6d9bbe2..000000000 --- a/core/lib/Thelia/Model/map/CustomerTableMap.php +++ /dev/null @@ -1,99 +0,0 @@ -setName('customer'); - $this->setPhpName('Customer'); - $this->setClassname('Thelia\\Model\\Customer'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('ref', 'Ref', 'VARCHAR', true, 50, null); - $this->addForeignKey('customer_title_id', 'CustomerTitleId', 'INTEGER', 'customer_title', 'id', false, null, null); - $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('address2', 'Address2', 'VARCHAR', false, 255, null); - $this->addColumn('address3', 'Address3', 'VARCHAR', false, 255, null); - $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', false, 10, null); - $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('cellphone', 'Cellphone', 'VARCHAR', false, 20, null); - $this->addColumn('email', 'Email', 'VARCHAR', false, 50, null); - $this->addColumn('password', 'Password', 'VARCHAR', false, 255, null); - $this->addColumn('algo', 'Algo', 'VARCHAR', false, 128, null); - $this->addColumn('salt', 'Salt', 'VARCHAR', false, 128, null); - $this->addColumn('reseller', 'Reseller', 'TINYINT', false, null, null); - $this->addColumn('lang', 'Lang', 'VARCHAR', false, 10, null); - $this->addColumn('sponsor', 'Sponsor', 'VARCHAR', false, 50, null); - $this->addColumn('discount', 'Discount', 'FLOAT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('customer_title_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Addresss'); - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'customer_id', ), 'CASCADE', 'RESTRICT', 'Orders'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // CustomerTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php deleted file mode 100755 index ed7bf6072..000000000 --- a/core/lib/Thelia/Model/map/CustomerTitleI18nTableMap.php +++ /dev/null @@ -1,60 +0,0 @@ -setName('customer_title_i18n'); - $this->setPhpName('CustomerTitleI18n'); - $this->setClassname('Thelia\\Model\\CustomerTitleI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'customer_title', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('short', 'Short', 'VARCHAR', false, 10, null); - $this->addColumn('long', 'Long', 'VARCHAR', false, 45, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('CustomerTitle', 'Thelia\\Model\\CustomerTitle', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // CustomerTitleI18nTableMap diff --git a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/map/CustomerTitleTableMap.php deleted file mode 100755 index 6fb527a1c..000000000 --- a/core/lib/Thelia/Model/map/CustomerTitleTableMap.php +++ /dev/null @@ -1,89 +0,0 @@ -setName('customer_title'); - $this->setPhpName('CustomerTitle'); - $this->setClassname('Thelia\\Model\\CustomerTitle'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('by_default', 'ByDefault', 'INTEGER', true, null, 0); - $this->addColumn('position', 'Position', 'VARCHAR', true, 45, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'SET NULL', 'RESTRICT', 'Customers'); - $this->addRelation('Address', 'Thelia\\Model\\Address', RelationMap::ONE_TO_MANY, array('id' => 'customer_title_id', ), 'RESTRICT', 'RESTRICT', 'Addresss'); - $this->addRelation('CustomerTitleI18n', 'Thelia\\Model\\CustomerTitleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'CustomerTitleI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'short, long', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // CustomerTitleTableMap diff --git a/core/lib/Thelia/Model/map/DelivzoneTableMap.php b/core/lib/Thelia/Model/map/DelivzoneTableMap.php deleted file mode 100755 index 379da0118..000000000 --- a/core/lib/Thelia/Model/map/DelivzoneTableMap.php +++ /dev/null @@ -1,78 +0,0 @@ -setName('delivzone'); - $this->setPhpName('Delivzone'); - $this->setClassname('Thelia\\Model\\Delivzone'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('area_id', 'AreaId', 'INTEGER', 'area', 'id', false, null, null); - $this->addColumn('delivery', 'Delivery', 'VARCHAR', true, 45, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Area', 'Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'SET NULL', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // DelivzoneTableMap diff --git a/core/lib/Thelia/Model/map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/map/DocumentI18nTableMap.php deleted file mode 100755 index ea10a0b8c..000000000 --- a/core/lib/Thelia/Model/map/DocumentI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('document_i18n'); - $this->setPhpName('DocumentI18n'); - $this->setClassname('Thelia\\Model\\DocumentI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'document', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // DocumentI18nTableMap diff --git a/core/lib/Thelia/Model/map/DocumentTableMap.php b/core/lib/Thelia/Model/map/DocumentTableMap.php deleted file mode 100755 index 69f0d90e9..000000000 --- a/core/lib/Thelia/Model/map/DocumentTableMap.php +++ /dev/null @@ -1,95 +0,0 @@ -setName('document'); - $this->setPhpName('Document'); - $this->setClassname('Thelia\\Model\\Document'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); - $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); - $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); - $this->addColumn('file', 'File', 'VARCHAR', true, 255, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('DocumentI18n', 'Thelia\\Model\\DocumentI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'DocumentI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // DocumentTableMap diff --git a/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php deleted file mode 100755 index d8f5ef074..000000000 --- a/core/lib/Thelia/Model/map/FeatureAvI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('feature_av_i18n'); - $this->setPhpName('FeatureAvI18n'); - $this->setClassname('Thelia\\Model\\FeatureAvI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'feature_av', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // FeatureAvI18nTableMap diff --git a/core/lib/Thelia/Model/map/FeatureAvTableMap.php b/core/lib/Thelia/Model/map/FeatureAvTableMap.php deleted file mode 100755 index ef1ed57f5..000000000 --- a/core/lib/Thelia/Model/map/FeatureAvTableMap.php +++ /dev/null @@ -1,88 +0,0 @@ -setName('feature_av'); - $this->setPhpName('FeatureAv'); - $this->setClassname('Thelia\\Model\\FeatureAv'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_av_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); - $this->addRelation('FeatureAvI18n', 'Thelia\\Model\\FeatureAvI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FeatureAvI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // FeatureAvTableMap diff --git a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php b/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php deleted file mode 100755 index 88efccc97..000000000 --- a/core/lib/Thelia/Model/map/FeatureCategoryTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('feature_category'); - $this->setPhpName('FeatureCategory'); - $this->setClassname('Thelia\\Model\\FeatureCategory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // FeatureCategoryTableMap diff --git a/core/lib/Thelia/Model/map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/map/FeatureI18nTableMap.php deleted file mode 100755 index 7f3ff771c..000000000 --- a/core/lib/Thelia/Model/map/FeatureI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('feature_i18n'); - $this->setPhpName('FeatureI18n'); - $this->setClassname('Thelia\\Model\\FeatureI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'feature', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // FeatureI18nTableMap diff --git a/core/lib/Thelia/Model/map/FeatureProdTableMap.php b/core/lib/Thelia/Model/map/FeatureProdTableMap.php deleted file mode 100755 index d55478e91..000000000 --- a/core/lib/Thelia/Model/map/FeatureProdTableMap.php +++ /dev/null @@ -1,83 +0,0 @@ -setName('feature_prod'); - $this->setPhpName('FeatureProd'); - $this->setClassname('Thelia\\Model\\FeatureProd'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); - $this->addForeignKey('feature_id', 'FeatureId', 'INTEGER', 'feature', 'id', true, null, null); - $this->addForeignKey('feature_av_id', 'FeatureAvId', 'INTEGER', 'feature_av', 'id', false, null, null); - $this->addColumn('by_default', 'ByDefault', 'VARCHAR', false, 255, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Feature', 'Thelia\\Model\\Feature', RelationMap::MANY_TO_ONE, array('feature_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::MANY_TO_ONE, array('feature_av_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // FeatureProdTableMap diff --git a/core/lib/Thelia/Model/map/FeatureTableMap.php b/core/lib/Thelia/Model/map/FeatureTableMap.php deleted file mode 100755 index af23df32e..000000000 --- a/core/lib/Thelia/Model/map/FeatureTableMap.php +++ /dev/null @@ -1,91 +0,0 @@ -setName('feature'); - $this->setPhpName('Feature'); - $this->setClassname('Thelia\\Model\\Feature'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('visible', 'Visible', 'INTEGER', false, null, 0); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('FeatureAv', 'Thelia\\Model\\FeatureAv', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureAvs'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); - $this->addRelation('FeatureCategory', 'Thelia\\Model\\FeatureCategory', RelationMap::ONE_TO_MANY, array('id' => 'feature_id', ), 'CASCADE', 'RESTRICT', 'FeatureCategorys'); - $this->addRelation('FeatureI18n', 'Thelia\\Model\\FeatureI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'FeatureI18ns'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categorys'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // FeatureTableMap diff --git a/core/lib/Thelia/Model/map/FolderI18nTableMap.php b/core/lib/Thelia/Model/map/FolderI18nTableMap.php deleted file mode 100755 index a156d791f..000000000 --- a/core/lib/Thelia/Model/map/FolderI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('folder_i18n'); - $this->setPhpName('FolderI18n'); - $this->setClassname('Thelia\\Model\\FolderI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'folder', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * 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() - -} // FolderI18nTableMap diff --git a/core/lib/Thelia/Model/map/FolderTableMap.php b/core/lib/Thelia/Model/map/FolderTableMap.php deleted file mode 100755 index 083d2c77d..000000000 --- a/core/lib/Thelia/Model/map/FolderTableMap.php +++ /dev/null @@ -1,108 +0,0 @@ -setName('folder'); - $this->setPhpName('Folder'); - $this->setClassname('Thelia\\Model\\Folder'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('parent', 'Parent', 'INTEGER', true, null, null); - $this->addColumn('link', 'Link', 'VARCHAR', false, 255, null); - $this->addColumn('visible', 'Visible', 'TINYINT', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', 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() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Documents'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); - $this->addRelation('ContentFolder', 'Thelia\\Model\\ContentFolder', RelationMap::ONE_TO_MANY, array('id' => 'folder_id', ), 'CASCADE', 'RESTRICT', 'ContentFolders'); - $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'); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Contents'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - 'versionable' => array ( - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'true', - 'log_created_by' => 'true', - 'log_comment' => 'false', - 'version_created_at_column' => 'version_created_at', - 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', -), - ); - } // getBehaviors() - -} // FolderTableMap diff --git a/core/lib/Thelia/Model/map/FolderVersionTableMap.php b/core/lib/Thelia/Model/map/FolderVersionTableMap.php deleted file mode 100755 index 0de9d13c2..000000000 --- a/core/lib/Thelia/Model/map/FolderVersionTableMap.php +++ /dev/null @@ -1,66 +0,0 @@ -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/GroupI18nTableMap.php b/core/lib/Thelia/Model/map/GroupI18nTableMap.php deleted file mode 100755 index 122508186..000000000 --- a/core/lib/Thelia/Model/map/GroupI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('group_i18n'); - $this->setPhpName('GroupI18n'); - $this->setClassname('Thelia\\Model\\GroupI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'group', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // GroupI18nTableMap diff --git a/core/lib/Thelia/Model/map/GroupModuleTableMap.php b/core/lib/Thelia/Model/map/GroupModuleTableMap.php deleted file mode 100755 index 0db6fd037..000000000 --- a/core/lib/Thelia/Model/map/GroupModuleTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('group_module'); - $this->setPhpName('GroupModule'); - $this->setClassname('Thelia\\Model\\GroupModule'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('group_id', 'GroupId', 'INTEGER', 'group', 'id', true, null, null); - $this->addForeignKey('module_id', 'ModuleId', 'INTEGER', 'module', 'id', false, null, null); - $this->addColumn('access', 'Access', 'TINYINT', false, null, 0); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE'); - $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // GroupModuleTableMap diff --git a/core/lib/Thelia/Model/map/GroupResourceTableMap.php b/core/lib/Thelia/Model/map/GroupResourceTableMap.php deleted file mode 100755 index b434456af..000000000 --- a/core/lib/Thelia/Model/map/GroupResourceTableMap.php +++ /dev/null @@ -1,82 +0,0 @@ -setName('group_resource'); - $this->setPhpName('GroupResource'); - $this->setClassname('Thelia\\Model\\GroupResource'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('group_id', 'GroupId', 'INTEGER' , 'group', 'id', true, null, null); - $this->addForeignPrimaryKey('resource_id', 'ResourceId', 'INTEGER' , 'resource', 'id', true, null, null); - $this->addColumn('read', 'Read', 'TINYINT', false, null, 0); - $this->addColumn('write', 'Write', 'TINYINT', false, null, 0); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // GroupResourceTableMap diff --git a/core/lib/Thelia/Model/map/GroupTableMap.php b/core/lib/Thelia/Model/map/GroupTableMap.php deleted file mode 100755 index fa5480a6d..000000000 --- a/core/lib/Thelia/Model/map/GroupTableMap.php +++ /dev/null @@ -1,91 +0,0 @@ -setName('group'); - $this->setPhpName('Group'); - $this->setClassname('Thelia\\Model\\Group'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AdminGroup', 'Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); - $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); - $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'CASCADE', 'GroupModules'); - $this->addRelation('GroupI18n', 'Thelia\\Model\\GroupI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'GroupI18ns'); - $this->addRelation('Admin', 'Thelia\\Model\\Admin', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Admins'); - $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Resources'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // GroupTableMap diff --git a/core/lib/Thelia/Model/map/ImageI18nTableMap.php b/core/lib/Thelia/Model/map/ImageI18nTableMap.php deleted file mode 100755 index 111945b6f..000000000 --- a/core/lib/Thelia/Model/map/ImageI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('image_i18n'); - $this->setPhpName('ImageI18n'); - $this->setClassname('Thelia\\Model\\ImageI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'image', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // ImageI18nTableMap diff --git a/core/lib/Thelia/Model/map/ImageTableMap.php b/core/lib/Thelia/Model/map/ImageTableMap.php deleted file mode 100755 index 7c9dd1a5b..000000000 --- a/core/lib/Thelia/Model/map/ImageTableMap.php +++ /dev/null @@ -1,95 +0,0 @@ -setName('image'); - $this->setPhpName('Image'); - $this->setClassname('Thelia\\Model\\Image'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); - $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); - $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); - $this->addColumn('file', 'File', 'VARCHAR', true, 255, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('ImageI18n', 'Thelia\\Model\\ImageI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ImageI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // ImageTableMap diff --git a/core/lib/Thelia/Model/map/LangTableMap.php b/core/lib/Thelia/Model/map/LangTableMap.php deleted file mode 100755 index d70450386..000000000 --- a/core/lib/Thelia/Model/map/LangTableMap.php +++ /dev/null @@ -1,80 +0,0 @@ -setName('lang'); - $this->setPhpName('Lang'); - $this->setClassname('Thelia\\Model\\Lang'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('title', 'Title', 'VARCHAR', false, 100, null); - $this->addColumn('code', 'Code', 'VARCHAR', false, 10, null); - $this->addColumn('locale', 'Locale', 'VARCHAR', false, 45, null); - $this->addColumn('url', 'Url', 'VARCHAR', false, 255, null); - $this->addColumn('by_default', 'ByDefault', 'TINYINT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // LangTableMap diff --git a/core/lib/Thelia/Model/map/MessageI18nTableMap.php b/core/lib/Thelia/Model/map/MessageI18nTableMap.php deleted file mode 100755 index fb92e2048..000000000 --- a/core/lib/Thelia/Model/map/MessageI18nTableMap.php +++ /dev/null @@ -1,61 +0,0 @@ -setName('message_i18n'); - $this->setPhpName('MessageI18n'); - $this->setClassname('Thelia\\Model\\MessageI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'message', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'LONGVARCHAR', false, null, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('description_html', 'DescriptionHtml', 'CLOB', false, null, null); - // validators - } // initialize() - - /** - * 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() - -} // MessageI18nTableMap diff --git a/core/lib/Thelia/Model/map/MessageTableMap.php b/core/lib/Thelia/Model/map/MessageTableMap.php deleted file mode 100755 index f0240f508..000000000 --- a/core/lib/Thelia/Model/map/MessageTableMap.php +++ /dev/null @@ -1,102 +0,0 @@ -setName('message'); - $this->setPhpName('Message'); - $this->setClassname('Thelia\\Model\\Message'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 45, null); - $this->addColumn('secured', 'Secured', 'TINYINT', false, null, null); - $this->addColumn('ref', 'Ref', 'VARCHAR', false, 255, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('version', 'Version', 'INTEGER', false, null, 0); - $this->addColumn('version_created_at', 'VersionCreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('version_created_by', 'VersionCreatedBy', 'VARCHAR', false, 100, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - 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() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, description_html', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - 'versionable' => array ( - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'true', - 'log_created_by' => 'true', - 'log_comment' => 'false', - 'version_created_at_column' => 'version_created_at', - 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', -), - ); - } // getBehaviors() - -} // MessageTableMap diff --git a/core/lib/Thelia/Model/map/MessageVersionTableMap.php b/core/lib/Thelia/Model/map/MessageVersionTableMap.php deleted file mode 100755 index 670d1aad2..000000000 --- a/core/lib/Thelia/Model/map/MessageVersionTableMap.php +++ /dev/null @@ -1,65 +0,0 @@ -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/ModuleI18nTableMap.php b/core/lib/Thelia/Model/map/ModuleI18nTableMap.php deleted file mode 100755 index 61247bcf3..000000000 --- a/core/lib/Thelia/Model/map/ModuleI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('module_i18n'); - $this->setPhpName('ModuleI18n'); - $this->setClassname('Thelia\\Model\\ModuleI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'module', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Module', 'Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // ModuleI18nTableMap diff --git a/core/lib/Thelia/Model/map/ModuleTableMap.php b/core/lib/Thelia/Model/map/ModuleTableMap.php deleted file mode 100755 index 5588f4af6..000000000 --- a/core/lib/Thelia/Model/map/ModuleTableMap.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('module'); - $this->setPhpName('Module'); - $this->setClassname('Thelia\\Model\\Module'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 55, null); - $this->addColumn('type', 'Type', 'TINYINT', true, null, null); - $this->addColumn('activate', 'Activate', 'TINYINT', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('GroupModule', 'Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); - $this->addRelation('ModuleI18n', 'Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // ModuleTableMap diff --git a/core/lib/Thelia/Model/map/OrderAddressTableMap.php b/core/lib/Thelia/Model/map/OrderAddressTableMap.php deleted file mode 100755 index 0ac4dde41..000000000 --- a/core/lib/Thelia/Model/map/OrderAddressTableMap.php +++ /dev/null @@ -1,88 +0,0 @@ -setName('order_address'); - $this->setPhpName('OrderAddress'); - $this->setClassname('Thelia\\Model\\OrderAddress'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('customer_title_id', 'CustomerTitleId', 'INTEGER', false, null, null); - $this->addColumn('company', 'Company', 'VARCHAR', false, 255, null); - $this->addColumn('firstname', 'Firstname', 'VARCHAR', true, 255, null); - $this->addColumn('lastname', 'Lastname', 'VARCHAR', true, 255, null); - $this->addColumn('address1', 'Address1', 'VARCHAR', true, 255, null); - $this->addColumn('address2', 'Address2', 'VARCHAR', false, 255, null); - $this->addColumn('address3', 'Address3', 'VARCHAR', false, 255, null); - $this->addColumn('zipcode', 'Zipcode', 'VARCHAR', true, 10, null); - $this->addColumn('city', 'City', 'VARCHAR', true, 255, null); - $this->addColumn('phone', 'Phone', 'VARCHAR', false, 20, null); - $this->addColumn('country_id', 'CountryId', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('OrderRelatedByAddressInvoice', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_invoice', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressInvoice'); - $this->addRelation('OrderRelatedByAddressDelivery', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'address_delivery', ), 'SET NULL', 'RESTRICT', 'OrdersRelatedByAddressDelivery'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // OrderAddressTableMap diff --git a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php b/core/lib/Thelia/Model/map/OrderFeatureTableMap.php deleted file mode 100755 index 0f3a43ffd..000000000 --- a/core/lib/Thelia/Model/map/OrderFeatureTableMap.php +++ /dev/null @@ -1,79 +0,0 @@ -setName('order_feature'); - $this->setPhpName('OrderFeature'); - $this->setClassname('Thelia\\Model\\OrderFeature'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('order_product_id', 'OrderProductId', 'INTEGER', 'order_product', 'id', true, null, null); - $this->addColumn('feature_desc', 'FeatureDesc', 'VARCHAR', false, 255, null); - $this->addColumn('feature_av_desc', 'FeatureAvDesc', 'VARCHAR', false, 255, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::MANY_TO_ONE, array('order_product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // OrderFeatureTableMap diff --git a/core/lib/Thelia/Model/map/OrderProductTableMap.php b/core/lib/Thelia/Model/map/OrderProductTableMap.php deleted file mode 100755 index 07abe778f..000000000 --- a/core/lib/Thelia/Model/map/OrderProductTableMap.php +++ /dev/null @@ -1,86 +0,0 @@ -setName('order_product'); - $this->setPhpName('OrderProduct'); - $this->setClassname('Thelia\\Model\\OrderProduct'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('order_id', 'OrderId', 'INTEGER', 'order', 'id', true, null, null); - $this->addColumn('product_ref', 'ProductRef', 'VARCHAR', false, 255, null); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('quantity', 'Quantity', 'FLOAT', true, null, null); - $this->addColumn('price', 'Price', 'FLOAT', true, null, null); - $this->addColumn('tax', 'Tax', 'FLOAT', false, null, null); - $this->addColumn('parent', 'Parent', 'INTEGER', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::MANY_TO_ONE, array('order_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderFeature', 'Thelia\\Model\\OrderFeature', RelationMap::ONE_TO_MANY, array('id' => 'order_product_id', ), 'CASCADE', 'RESTRICT', 'OrderFeatures'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // OrderProductTableMap diff --git a/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php deleted file mode 100755 index 594f99f86..000000000 --- a/core/lib/Thelia/Model/map/OrderStatusI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('order_status_i18n'); - $this->setPhpName('OrderStatusI18n'); - $this->setClassname('Thelia\\Model\\OrderStatusI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'order_status', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // OrderStatusI18nTableMap diff --git a/core/lib/Thelia/Model/map/OrderStatusTableMap.php b/core/lib/Thelia/Model/map/OrderStatusTableMap.php deleted file mode 100755 index 66284e02f..000000000 --- a/core/lib/Thelia/Model/map/OrderStatusTableMap.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('order_status'); - $this->setPhpName('OrderStatus'); - $this->setClassname('Thelia\\Model\\OrderStatus'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Order', 'Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'status_id', ), 'SET NULL', 'RESTRICT', 'Orders'); - $this->addRelation('OrderStatusI18n', 'Thelia\\Model\\OrderStatusI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'OrderStatusI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // OrderStatusTableMap diff --git a/core/lib/Thelia/Model/map/OrderTableMap.php b/core/lib/Thelia/Model/map/OrderTableMap.php deleted file mode 100755 index 1b7b04013..000000000 --- a/core/lib/Thelia/Model/map/OrderTableMap.php +++ /dev/null @@ -1,97 +0,0 @@ -setName('order'); - $this->setPhpName('Order'); - $this->setClassname('Thelia\\Model\\Order'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('ref', 'Ref', 'VARCHAR', false, 45, null); - $this->addForeignKey('customer_id', 'CustomerId', 'INTEGER', 'customer', 'id', true, null, null); - $this->addForeignKey('address_invoice', 'AddressInvoice', 'INTEGER', 'order_address', 'id', false, null, null); - $this->addForeignKey('address_delivery', 'AddressDelivery', 'INTEGER', 'order_address', 'id', false, null, null); - $this->addColumn('invoice_date', 'InvoiceDate', 'DATE', false, null, null); - $this->addForeignKey('currency_id', 'CurrencyId', 'INTEGER', 'currency', 'id', false, null, null); - $this->addColumn('currency_rate', 'CurrencyRate', 'FLOAT', true, null, null); - $this->addColumn('transaction', 'Transaction', 'VARCHAR', false, 100, null); - $this->addColumn('delivery_num', 'DeliveryNum', 'VARCHAR', false, 100, null); - $this->addColumn('invoice', 'Invoice', 'VARCHAR', false, 100, null); - $this->addColumn('postage', 'Postage', 'FLOAT', false, null, null); - $this->addColumn('payment', 'Payment', 'VARCHAR', true, 45, null); - $this->addColumn('carrier', 'Carrier', 'VARCHAR', true, 45, null); - $this->addForeignKey('status_id', 'StatusId', 'INTEGER', 'order_status', 'id', false, null, null); - $this->addColumn('lang', 'Lang', 'VARCHAR', true, 10, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Currency', 'Thelia\\Model\\Currency', RelationMap::MANY_TO_ONE, array('currency_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('Customer', 'Thelia\\Model\\Customer', RelationMap::MANY_TO_ONE, array('customer_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressInvoice', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_invoice' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderAddressRelatedByAddressDelivery', 'Thelia\\Model\\OrderAddress', RelationMap::MANY_TO_ONE, array('address_delivery' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderStatus', 'Thelia\\Model\\OrderStatus', RelationMap::MANY_TO_ONE, array('status_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('OrderProduct', 'Thelia\\Model\\OrderProduct', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'OrderProducts'); - $this->addRelation('CouponOrder', 'Thelia\\Model\\CouponOrder', RelationMap::ONE_TO_MANY, array('id' => 'order_id', ), 'CASCADE', 'RESTRICT', 'CouponOrders'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // OrderTableMap diff --git a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php b/core/lib/Thelia/Model/map/ProductCategoryTableMap.php deleted file mode 100755 index 59c67b32b..000000000 --- a/core/lib/Thelia/Model/map/ProductCategoryTableMap.php +++ /dev/null @@ -1,79 +0,0 @@ -setName('product_category'); - $this->setPhpName('ProductCategory'); - $this->setClassname('Thelia\\Model\\ProductCategory'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - $this->setIsCrossRef(true); - // columns - $this->addForeignPrimaryKey('product_id', 'ProductId', 'INTEGER' , 'product', 'id', true, null, null); - $this->addForeignPrimaryKey('category_id', 'CategoryId', 'INTEGER' , 'category', 'id', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // ProductCategoryTableMap diff --git a/core/lib/Thelia/Model/map/ProductI18nTableMap.php b/core/lib/Thelia/Model/map/ProductI18nTableMap.php deleted file mode 100755 index f94fe6e4b..000000000 --- a/core/lib/Thelia/Model/map/ProductI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('product_i18n'); - $this->setPhpName('ProductI18n'); - $this->setClassname('Thelia\\Model\\ProductI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'product', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * 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() - -} // ProductI18nTableMap diff --git a/core/lib/Thelia/Model/map/ProductTableMap.php b/core/lib/Thelia/Model/map/ProductTableMap.php deleted file mode 100755 index 6ec4aa4e1..000000000 --- a/core/lib/Thelia/Model/map/ProductTableMap.php +++ /dev/null @@ -1,123 +0,0 @@ -setName('product'); - $this->setPhpName('Product'); - $this->setClassname('Thelia\\Model\\Product'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('tax_rule_id', 'TaxRuleId', 'INTEGER', 'tax_rule', 'id', false, null, null); - $this->addColumn('ref', 'Ref', 'VARCHAR', true, 255, null); - $this->addColumn('price', 'Price', 'FLOAT', true, null, null); - $this->addColumn('price2', 'Price2', 'FLOAT', false, null, null); - $this->addColumn('ecotax', 'Ecotax', 'FLOAT', false, null, null); - $this->addColumn('newness', 'Newness', 'TINYINT', false, null, 0); - $this->addColumn('promo', 'Promo', 'TINYINT', false, null, 0); - $this->addColumn('quantity', 'Quantity', 'INTEGER', false, null, 0); - $this->addColumn('visible', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('weight', 'Weight', 'FLOAT', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', 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() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('ProductCategory', 'Thelia\\Model\\ProductCategory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ProductCategorys'); - $this->addRelation('FeatureProd', 'Thelia\\Model\\FeatureProd', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'FeatureProds'); - $this->addRelation('Stock', 'Thelia\\Model\\Stock', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Stocks'); - $this->addRelation('ContentAssoc', 'Thelia\\Model\\ContentAssoc', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'ContentAssocs'); - $this->addRelation('Image', 'Thelia\\Model\\Image', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Images'); - $this->addRelation('Document', 'Thelia\\Model\\Document', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Documents'); - $this->addRelation('AccessoryRelatedByProductId', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'AccessorysRelatedByProductId'); - $this->addRelation('AccessoryRelatedByAccessory', 'Thelia\\Model\\Accessory', RelationMap::ONE_TO_MANY, array('id' => 'accessory', ), 'CASCADE', 'RESTRICT', 'AccessorysRelatedByAccessory'); - $this->addRelation('Rewriting', 'Thelia\\Model\\Rewriting', RelationMap::ONE_TO_MANY, array('id' => 'product_id', ), 'CASCADE', 'RESTRICT', 'Rewritings'); - $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'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Categorys'); - $this->addRelation('ProductRelatedByAccessory', 'Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'ProductsRelatedByAccessory'); - $this->addRelation('ProductRelatedByProductId', 'Thelia\\Model\\Product', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'ProductsRelatedByProductId'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - 'versionable' => array ( - 'version_column' => 'version', - 'version_table' => '', - 'log_created_at' => 'true', - 'log_created_by' => 'true', - 'log_comment' => 'false', - 'version_created_at_column' => 'version_created_at', - 'version_created_by_column' => 'version_created_by', - 'version_comment_column' => 'version_comment', -), - ); - } // getBehaviors() - -} // ProductTableMap diff --git a/core/lib/Thelia/Model/map/ProductVersionTableMap.php b/core/lib/Thelia/Model/map/ProductVersionTableMap.php deleted file mode 100755 index 490fb28c1..000000000 --- a/core/lib/Thelia/Model/map/ProductVersionTableMap.php +++ /dev/null @@ -1,73 +0,0 @@ -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('quantity', 'Quantity', 'INTEGER', false, null, 0); - $this->addColumn('visible', 'Visible', 'TINYINT', true, null, 0); - $this->addColumn('weight', 'Weight', 'FLOAT', false, null, null); - $this->addColumn('position', 'Position', 'INTEGER', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', 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/map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/map/ResourceI18nTableMap.php deleted file mode 100755 index 9bf1931e5..000000000 --- a/core/lib/Thelia/Model/map/ResourceI18nTableMap.php +++ /dev/null @@ -1,62 +0,0 @@ -setName('resource_i18n'); - $this->setPhpName('ResourceI18n'); - $this->setClassname('Thelia\\Model\\ResourceI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'resource', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'CLOB', false, null, null); - $this->addColumn('chapo', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('postscriptum', 'Postscriptum', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Resource', 'Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // ResourceI18nTableMap diff --git a/core/lib/Thelia/Model/map/ResourceTableMap.php b/core/lib/Thelia/Model/map/ResourceTableMap.php deleted file mode 100755 index 30c99ffc3..000000000 --- a/core/lib/Thelia/Model/map/ResourceTableMap.php +++ /dev/null @@ -1,88 +0,0 @@ -setName('resource'); - $this->setPhpName('Resource'); - $this->setClassname('Thelia\\Model\\Resource'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('GroupResource', 'Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); - $this->addRelation('ResourceI18n', 'Thelia\\Model\\ResourceI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ResourceI18ns'); - $this->addRelation('Group', 'Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description, chapo, postscriptum', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // ResourceTableMap diff --git a/core/lib/Thelia/Model/map/RewritingTableMap.php b/core/lib/Thelia/Model/map/RewritingTableMap.php deleted file mode 100755 index cbf7c5045..000000000 --- a/core/lib/Thelia/Model/map/RewritingTableMap.php +++ /dev/null @@ -1,84 +0,0 @@ -setName('rewriting'); - $this->setPhpName('Rewriting'); - $this->setClassname('Thelia\\Model\\Rewriting'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('url', 'Url', 'VARCHAR', true, 255, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', false, null, null); - $this->addForeignKey('category_id', 'CategoryId', 'INTEGER', 'category', 'id', false, null, null); - $this->addForeignKey('folder_id', 'FolderId', 'INTEGER', 'folder', 'id', false, null, null); - $this->addForeignKey('content_id', 'ContentId', 'INTEGER', 'content', 'id', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Category', 'Thelia\\Model\\Category', RelationMap::MANY_TO_ONE, array('category_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Folder', 'Thelia\\Model\\Folder', RelationMap::MANY_TO_ONE, array('folder_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Content', 'Thelia\\Model\\Content', RelationMap::MANY_TO_ONE, array('content_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // RewritingTableMap diff --git a/core/lib/Thelia/Model/map/StockTableMap.php b/core/lib/Thelia/Model/map/StockTableMap.php deleted file mode 100755 index 1b32f03df..000000000 --- a/core/lib/Thelia/Model/map/StockTableMap.php +++ /dev/null @@ -1,81 +0,0 @@ -setName('stock'); - $this->setPhpName('Stock'); - $this->setClassname('Thelia\\Model\\Stock'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('combination_id', 'CombinationId', 'INTEGER', 'combination', 'id', false, null, null); - $this->addForeignKey('product_id', 'ProductId', 'INTEGER', 'product', 'id', true, null, null); - $this->addColumn('increase', 'Increase', 'FLOAT', false, null, null); - $this->addColumn('value', 'Value', 'FLOAT', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Combination', 'Thelia\\Model\\Combination', RelationMap::MANY_TO_ONE, array('combination_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::MANY_TO_ONE, array('product_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // StockTableMap diff --git a/core/lib/Thelia/Model/map/TaxI18nTableMap.php b/core/lib/Thelia/Model/map/TaxI18nTableMap.php deleted file mode 100755 index 80aab3e83..000000000 --- a/core/lib/Thelia/Model/map/TaxI18nTableMap.php +++ /dev/null @@ -1,60 +0,0 @@ -setName('tax_i18n'); - $this->setPhpName('TaxI18n'); - $this->setClassname('Thelia\\Model\\TaxI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'tax', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // TaxI18nTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php b/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php deleted file mode 100755 index cf23d4adf..000000000 --- a/core/lib/Thelia/Model/map/TaxRuleCountryTableMap.php +++ /dev/null @@ -1,82 +0,0 @@ -setName('tax_rule_country'); - $this->setPhpName('TaxRuleCountry'); - $this->setClassname('Thelia\\Model\\TaxRuleCountry'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('tax_rule_id', 'TaxRuleId', 'INTEGER', 'tax_rule', 'id', false, null, null); - $this->addForeignKey('country_id', 'CountryId', 'INTEGER', 'country', 'id', false, null, null); - $this->addForeignKey('tax_id', 'TaxId', 'INTEGER', 'tax', 'id', false, null, null); - $this->addColumn('none', 'None', 'TINYINT', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Tax', 'Thelia\\Model\\Tax', RelationMap::MANY_TO_ONE, array('tax_id' => 'id', ), 'SET NULL', 'RESTRICT'); - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('tax_rule_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Country', 'Thelia\\Model\\Country', RelationMap::MANY_TO_ONE, array('country_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - ); - } // getBehaviors() - -} // TaxRuleCountryTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php deleted file mode 100755 index b0d07244c..000000000 --- a/core/lib/Thelia/Model/map/TaxRuleI18nTableMap.php +++ /dev/null @@ -1,58 +0,0 @@ -setName('tax_rule_i18n'); - $this->setPhpName('TaxRuleI18n'); - $this->setClassname('Thelia\\Model\\TaxRuleI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('id', 'Id', 'INTEGER' , 'tax_rule', 'id', true, null, null); - $this->addPrimaryKey('locale', 'Locale', 'VARCHAR', true, 5, 'en_US'); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('TaxRule', 'Thelia\\Model\\TaxRule', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - -} // TaxRuleI18nTableMap diff --git a/core/lib/Thelia/Model/map/TaxRuleTableMap.php b/core/lib/Thelia/Model/map/TaxRuleTableMap.php deleted file mode 100755 index 64574acef..000000000 --- a/core/lib/Thelia/Model/map/TaxRuleTableMap.php +++ /dev/null @@ -1,90 +0,0 @@ -setName('tax_rule'); - $this->setPhpName('TaxRule'); - $this->setClassname('Thelia\\Model\\TaxRule'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('code', 'Code', 'VARCHAR', false, 45, null); - $this->addColumn('title', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('description', 'Description', 'LONGVARCHAR', false, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Product', 'Thelia\\Model\\Product', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'SET NULL', 'RESTRICT', 'Products'); - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_rule_id', ), 'CASCADE', 'RESTRICT', 'TaxRuleCountrys'); - $this->addRelation('TaxRuleI18n', 'Thelia\\Model\\TaxRuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TaxRuleI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => '', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // TaxRuleTableMap diff --git a/core/lib/Thelia/Model/map/TaxTableMap.php b/core/lib/Thelia/Model/map/TaxTableMap.php deleted file mode 100755 index c852fc8d4..000000000 --- a/core/lib/Thelia/Model/map/TaxTableMap.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('tax'); - $this->setPhpName('Tax'); - $this->setClassname('Thelia\\Model\\Tax'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); - $this->addColumn('rate', 'Rate', 'FLOAT', true, null, null); - $this->addColumn('created_at', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('updated_at', 'UpdatedAt', 'TIMESTAMP', false, null, null); - // validators - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('TaxRuleCountry', 'Thelia\\Model\\TaxRuleCountry', RelationMap::ONE_TO_MANY, array('id' => 'tax_id', ), 'SET NULL', 'RESTRICT', 'TaxRuleCountrys'); - $this->addRelation('TaxI18n', 'Thelia\\Model\\TaxI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'TaxI18ns'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array ( - 'create_column' => 'created_at', - 'update_column' => 'updated_at', - 'disable_updated_at' => 'false', -), - 'i18n' => array ( - 'i18n_table' => '%TABLE%_i18n', - 'i18n_phpname' => '%PHPNAME%I18n', - 'i18n_columns' => 'title, description', - 'i18n_pk_name' => NULL, - 'locale_column' => 'locale', - 'default_locale' => NULL, - 'locale_alias' => '', -), - ); - } // getBehaviors() - -} // TaxTableMap diff --git a/core/lib/Thelia/Model/om/BaseAccessory.php b/core/lib/Thelia/Model/om/BaseAccessory.php deleted file mode 100755 index d01346c03..000000000 --- a/core/lib/Thelia/Model/om/BaseAccessory.php +++ /dev/null @@ -1,1329 +0,0 @@ -id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [accessory] column value. - * - * @return int - */ - public function getAccessory() - { - return $this->accessory; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Accessory The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AccessoryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return Accessory The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = AccessoryPeer::PRODUCT_ID; - } - - if ($this->aProductRelatedByProductId !== null && $this->aProductRelatedByProductId->getId() !== $v) { - $this->aProductRelatedByProductId = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [accessory] column. - * - * @param int $v new value - * @return Accessory The current object (for fluent API support) - */ - public function setAccessory($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->accessory !== $v) { - $this->accessory = $v; - $this->modifiedColumns[] = AccessoryPeer::ACCESSORY; - } - - if ($this->aProductRelatedByAccessory !== null && $this->aProductRelatedByAccessory->getId() !== $v) { - $this->aProductRelatedByAccessory = null; - } - - - return $this; - } // setAccessory() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Accessory The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = AccessoryPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Accessory The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AccessoryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Accessory The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->accessory = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->position = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = AccessoryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Accessory object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProductRelatedByProductId !== null && $this->product_id !== $this->aProductRelatedByProductId->getId()) { - $this->aProductRelatedByProductId = null; - } - if ($this->aProductRelatedByAccessory !== null && $this->accessory !== $this->aProductRelatedByAccessory->getId()) { - $this->aProductRelatedByAccessory = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AccessoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProductRelatedByProductId = null; - $this->aProductRelatedByAccessory = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AccessoryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AccessoryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AccessoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AccessoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AccessoryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProductRelatedByProductId !== null) { - if ($this->aProductRelatedByProductId->isModified() || $this->aProductRelatedByProductId->isNew()) { - $affectedRows += $this->aProductRelatedByProductId->save($con); - } - $this->setProductRelatedByProductId($this->aProductRelatedByProductId); - } - - if ($this->aProductRelatedByAccessory !== null) { - if ($this->aProductRelatedByAccessory->isModified() || $this->aProductRelatedByAccessory->isNew()) { - $affectedRows += $this->aProductRelatedByAccessory->save($con); - } - $this->setProductRelatedByAccessory($this->aProductRelatedByAccessory); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AccessoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) { - $modifiedColumns[':p' . $index++] = '`accessory`'; - } - if ($this->isColumnModified(AccessoryPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `accessory` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`accessory`': - $stmt->bindValue($identifier, $this->accessory, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProductRelatedByProductId !== null) { - if (!$this->aProductRelatedByProductId->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProductRelatedByProductId->getValidationFailures()); - } - } - - if ($this->aProductRelatedByAccessory !== null) { - if (!$this->aProductRelatedByAccessory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProductRelatedByAccessory->getValidationFailures()); - } - } - - - if (($retval = AccessoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getProductId(); - break; - case 2: - return $this->getAccessory(); - break; - case 3: - return $this->getPosition(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Accessory'][$this->getPrimaryKey()] = true; - $keys = AccessoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getProductId(), - $keys[2] => $this->getAccessory(), - $keys[3] => $this->getPosition(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProductRelatedByProductId) { - $result['ProductRelatedByProductId'] = $this->aProductRelatedByProductId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aProductRelatedByAccessory) { - $result['ProductRelatedByAccessory'] = $this->aProductRelatedByAccessory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AccessoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setProductId($value); - break; - case 2: - $this->setAccessory($value); - break; - case 3: - $this->setPosition($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AccessoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAccessory($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AccessoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(AccessoryPeer::ID)) $criteria->add(AccessoryPeer::ID, $this->id); - if ($this->isColumnModified(AccessoryPeer::PRODUCT_ID)) $criteria->add(AccessoryPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(AccessoryPeer::ACCESSORY)) $criteria->add(AccessoryPeer::ACCESSORY, $this->accessory); - if ($this->isColumnModified(AccessoryPeer::POSITION)) $criteria->add(AccessoryPeer::POSITION, $this->position); - if ($this->isColumnModified(AccessoryPeer::CREATED_AT)) $criteria->add(AccessoryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AccessoryPeer::UPDATED_AT)) $criteria->add(AccessoryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AccessoryPeer::DATABASE_NAME); - $criteria->add(AccessoryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Accessory (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setProductId($this->getProductId()); - $copyObj->setAccessory($this->getAccessory()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Accessory Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AccessoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AccessoryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Accessory The current object (for fluent API support) - * @throws PropelException - */ - public function setProductRelatedByProductId(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProductRelatedByProductId = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addAccessoryRelatedByProductId($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProductRelatedByProductId(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProductRelatedByProductId === null && ($this->product_id !== null) && $doQuery) { - $this->aProductRelatedByProductId = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProductRelatedByProductId->addAccessorysRelatedByProductId($this); - */ - } - - return $this->aProductRelatedByProductId; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Accessory The current object (for fluent API support) - * @throws PropelException - */ - public function setProductRelatedByAccessory(Product $v = null) - { - if ($v === null) { - $this->setAccessory(NULL); - } else { - $this->setAccessory($v->getId()); - } - - $this->aProductRelatedByAccessory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addAccessoryRelatedByAccessory($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProductRelatedByAccessory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProductRelatedByAccessory === null && ($this->accessory !== null) && $doQuery) { - $this->aProductRelatedByAccessory = ProductQuery::create()->findPk($this->accessory, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProductRelatedByAccessory->addAccessorysRelatedByAccessory($this); - */ - } - - return $this->aProductRelatedByAccessory; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->product_id = null; - $this->accessory = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProductRelatedByProductId instanceof Persistent) { - $this->aProductRelatedByProductId->clearAllReferences($deep); - } - if ($this->aProductRelatedByAccessory instanceof Persistent) { - $this->aProductRelatedByAccessory->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aProductRelatedByProductId = null; - $this->aProductRelatedByAccessory = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AccessoryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Accessory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AccessoryPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php b/core/lib/Thelia/Model/om/BaseAccessoryPeer.php deleted file mode 100755 index 7efbf476f..000000000 --- a/core/lib/Thelia/Model/om/BaseAccessoryPeer.php +++ /dev/null @@ -1,1371 +0,0 @@ - array ('Id', 'ProductId', 'Accessory', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'accessory', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID, AccessoryPeer::PRODUCT_ID, AccessoryPeer::ACCESSORY, AccessoryPeer::POSITION, AccessoryPeer::CREATED_AT, AccessoryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'ACCESSORY', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'accessory', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AccessoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'Accessory' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'accessory' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (AccessoryPeer::ID => 0, AccessoryPeer::PRODUCT_ID => 1, AccessoryPeer::ACCESSORY => 2, AccessoryPeer::POSITION => 3, AccessoryPeer::CREATED_AT => 4, AccessoryPeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'ACCESSORY' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'accessory' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AccessoryPeer::getFieldNames($toType); - $key = isset(AccessoryPeer::$fieldKeys[$fromType][$name]) ? AccessoryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AccessoryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AccessoryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AccessoryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AccessoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AccessoryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AccessoryPeer::ID); - $criteria->addSelectColumn(AccessoryPeer::PRODUCT_ID); - $criteria->addSelectColumn(AccessoryPeer::ACCESSORY); - $criteria->addSelectColumn(AccessoryPeer::POSITION); - $criteria->addSelectColumn(AccessoryPeer::CREATED_AT); - $criteria->addSelectColumn(AccessoryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.accessory'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Accessory - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AccessoryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AccessoryPeer::populateObjects(AccessoryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AccessoryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Accessory $obj A Accessory object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AccessoryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Accessory object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Accessory) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Accessory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AccessoryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Accessory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AccessoryPeer::$instances[$key])) { - return AccessoryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AccessoryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AccessoryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to accessory - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AccessoryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AccessoryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Accessory object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AccessoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AccessoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AccessoryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AccessoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AccessoryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProductRelatedByProductId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProductRelatedByAccessory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Accessory objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Accessory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - } - - AccessoryPeer::addSelectColumns($criteria); - $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AccessoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AccessoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Accessory) to $obj2 (Product) - $obj2->addAccessoryRelatedByProductId($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Accessory objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Accessory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - } - - AccessoryPeer::addSelectColumns($criteria); - $startcol = AccessoryPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AccessoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AccessoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Accessory) to $obj2 (Product) - $obj2->addAccessoryRelatedByAccessory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Accessory objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Accessory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - } - - AccessoryPeer::addSelectColumns($criteria); - $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AccessoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(AccessoryPeer::ACCESSORY, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AccessoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AccessoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Accessory) to the collection in $obj2 (Product) - $obj2->addAccessoryRelatedByProductId($obj1); - } // if joined row not null - - // Add objects for joined Product rows - - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ProductPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Accessory) to the collection in $obj3 (Product) - $obj3->addAccessoryRelatedByAccessory($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related ProductRelatedByProductId table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProductRelatedByProductId(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related ProductRelatedByAccessory table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProductRelatedByAccessory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AccessoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByProductId. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Accessory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProductRelatedByProductId(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - } - - AccessoryPeer::addSelectColumns($criteria); - $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS; - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AccessoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AccessoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Accessory objects pre-filled with all related objects except ProductRelatedByAccessory. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Accessory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProductRelatedByAccessory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - } - - AccessoryPeer::addSelectColumns($criteria); - $startcol2 = AccessoryPeer::NUM_HYDRATE_COLUMNS; - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AccessoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AccessoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AccessoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AccessoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME)->getTable(AccessoryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAccessoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAccessoryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AccessoryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AccessoryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Accessory or Criteria object. - * - * @param mixed $values Criteria or Accessory object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Accessory object - } - - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Accessory or Criteria object. - * - * @param mixed $values Criteria or Accessory object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AccessoryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AccessoryPeer::ID); - $value = $criteria->remove(AccessoryPeer::ID); - if ($value) { - $selectCriteria->add(AccessoryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AccessoryPeer::TABLE_NAME); - } - - } else { // $values is Accessory object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the accessory table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AccessoryPeer::TABLE_NAME, $con, AccessoryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AccessoryPeer::clearInstancePool(); - AccessoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Accessory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Accessory object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AccessoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Accessory) { // it's a model object - // invalidate the cache for this single object - AccessoryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AccessoryPeer::DATABASE_NAME); - $criteria->add(AccessoryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AccessoryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AccessoryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AccessoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Accessory object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Accessory $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AccessoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AccessoryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AccessoryPeer::DATABASE_NAME, AccessoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Accessory - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AccessoryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AccessoryPeer::DATABASE_NAME); - $criteria->add(AccessoryPeer::ID, $pk); - - $v = AccessoryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Accessory[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AccessoryPeer::DATABASE_NAME); - $criteria->add(AccessoryPeer::ID, $pks, Criteria::IN); - $objs = AccessoryPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAccessoryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAccessoryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php b/core/lib/Thelia/Model/om/BaseAccessoryQuery.php deleted file mode 100755 index 3f60bf748..000000000 --- a/core/lib/Thelia/Model/om/BaseAccessoryQuery.php +++ /dev/null @@ -1,749 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AccessoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AccessoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Accessory A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Accessory A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `product_id`, `accessory`, `position`, `created_at`, `updated_at` FROM `accessory` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Accessory(); - $obj->hydrate($row); - AccessoryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Accessory|Accessory[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Accessory[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AccessoryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AccessoryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AccessoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AccessoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProductRelatedByProductId() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the accessory column - * - * Example usage: - * - * $query->filterByAccessory(1234); // WHERE accessory = 1234 - * $query->filterByAccessory(array(12, 34)); // WHERE accessory IN (12, 34) - * $query->filterByAccessory(array('min' => 12)); // WHERE accessory >= 12 - * $query->filterByAccessory(array('max' => 12)); // WHERE accessory <= 12 - * - * - * @see filterByProductRelatedByAccessory() - * - * @param mixed $accessory The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByAccessory($accessory = null, $comparison = null) - { - if (is_array($accessory)) { - $useMinMax = false; - if (isset($accessory['min'])) { - $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($accessory['max'])) { - $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::ACCESSORY, $accessory, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(AccessoryPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(AccessoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AccessoryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProductRelatedByProductId($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AccessoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProductRelatedByProductId() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductRelatedByProductId relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function joinProductRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductRelatedByProductId'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductRelatedByProductId'); - } - - return $this; - } - - /** - * Use the ProductRelatedByProductId relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductRelatedByProductId($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByProductId', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AccessoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProductRelatedByAccessory($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AccessoryPeer::ACCESSORY, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProductRelatedByAccessory() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductRelatedByAccessory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function joinProductRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductRelatedByAccessory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductRelatedByAccessory'); - } - - return $this; - } - - /** - * Use the ProductRelatedByAccessory relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductRelatedByAccessory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductRelatedByAccessory', '\Thelia\Model\ProductQuery'); - } - - /** - * Exclude object from result - * - * @param Accessory $accessory Object to remove from the list of results - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function prune($accessory = null) - { - if ($accessory) { - $this->addUsingAlias(AccessoryPeer::ID, $accessory->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AccessoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AccessoryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AccessoryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AccessoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AccessoryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AccessoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AccessoryPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAddress.php b/core/lib/Thelia/Model/om/BaseAddress.php deleted file mode 100755 index 62db82dbe..000000000 --- a/core/lib/Thelia/Model/om/BaseAddress.php +++ /dev/null @@ -1,1892 +0,0 @@ -id; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [customer_id] column value. - * - * @return int - */ - public function getCustomerId() - { - return $this->customer_id; - } - - /** - * Get the [customer_title_id] column value. - * - * @return int - */ - public function getCustomerTitleId() - { - return $this->customer_title_id; - } - - /** - * Get the [company] column value. - * - * @return string - */ - public function getCompany() - { - return $this->company; - } - - /** - * Get the [firstname] column value. - * - * @return string - */ - public function getFirstname() - { - return $this->firstname; - } - - /** - * Get the [lastname] column value. - * - * @return string - */ - public function getLastname() - { - return $this->lastname; - } - - /** - * Get the [address1] column value. - * - * @return string - */ - public function getAddress1() - { - return $this->address1; - } - - /** - * Get the [address2] column value. - * - * @return string - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * Get the [address3] column value. - * - * @return string - */ - public function getAddress3() - { - return $this->address3; - } - - /** - * Get the [zipcode] column value. - * - * @return string - */ - public function getZipcode() - { - return $this->zipcode; - } - - /** - * Get the [city] column value. - * - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * Get the [country_id] column value. - * - * @return int - */ - public function getCountryId() - { - return $this->country_id; - } - - /** - * Get the [phone] column value. - * - * @return string - */ - public function getPhone() - { - return $this->phone; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Address The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AddressPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = AddressPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [customer_id] column. - * - * @param int $v new value - * @return Address The current object (for fluent API support) - */ - public function setCustomerId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->customer_id !== $v) { - $this->customer_id = $v; - $this->modifiedColumns[] = AddressPeer::CUSTOMER_ID; - } - - if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) { - $this->aCustomer = null; - } - - - return $this; - } // setCustomerId() - - /** - * Set the value of [customer_title_id] column. - * - * @param int $v new value - * @return Address The current object (for fluent API support) - */ - public function setCustomerTitleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->customer_title_id !== $v) { - $this->customer_title_id = $v; - $this->modifiedColumns[] = AddressPeer::CUSTOMER_TITLE_ID; - } - - if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { - $this->aCustomerTitle = null; - } - - - return $this; - } // setCustomerTitleId() - - /** - * Set the value of [company] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setCompany($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->company !== $v) { - $this->company = $v; - $this->modifiedColumns[] = AddressPeer::COMPANY; - } - - - return $this; - } // setCompany() - - /** - * Set the value of [firstname] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setFirstname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->firstname !== $v) { - $this->firstname = $v; - $this->modifiedColumns[] = AddressPeer::FIRSTNAME; - } - - - return $this; - } // setFirstname() - - /** - * Set the value of [lastname] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setLastname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lastname !== $v) { - $this->lastname = $v; - $this->modifiedColumns[] = AddressPeer::LASTNAME; - } - - - return $this; - } // setLastname() - - /** - * Set the value of [address1] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setAddress1($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address1 !== $v) { - $this->address1 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS1; - } - - - return $this; - } // setAddress1() - - /** - * Set the value of [address2] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setAddress2($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address2 !== $v) { - $this->address2 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS2; - } - - - return $this; - } // setAddress2() - - /** - * Set the value of [address3] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setAddress3($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address3 !== $v) { - $this->address3 = $v; - $this->modifiedColumns[] = AddressPeer::ADDRESS3; - } - - - return $this; - } // setAddress3() - - /** - * Set the value of [zipcode] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setZipcode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->zipcode !== $v) { - $this->zipcode = $v; - $this->modifiedColumns[] = AddressPeer::ZIPCODE; - } - - - return $this; - } // setZipcode() - - /** - * Set the value of [city] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setCity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->city !== $v) { - $this->city = $v; - $this->modifiedColumns[] = AddressPeer::CITY; - } - - - return $this; - } // setCity() - - /** - * Set the value of [country_id] column. - * - * @param int $v new value - * @return Address The current object (for fluent API support) - */ - public function setCountryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->country_id !== $v) { - $this->country_id = $v; - $this->modifiedColumns[] = AddressPeer::COUNTRY_ID; - } - - - return $this; - } // setCountryId() - - /** - * Set the value of [phone] column. - * - * @param string $v new value - * @return Address The current object (for fluent API support) - */ - public function setPhone($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->phone !== $v) { - $this->phone = $v; - $this->modifiedColumns[] = AddressPeer::PHONE; - } - - - return $this; - } // setPhone() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Address The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AddressPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Address The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AddressPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->customer_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->customer_title_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->company = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->firstname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->lastname = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->address1 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->address2 = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->address3 = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->zipcode = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->city = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; - $this->country_id = ($row[$startcol + 12] !== null) ? (int) $row[$startcol + 12] : null; - $this->phone = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->created_at = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; - $this->updated_at = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 16; // 16 = AddressPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Address object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { - $this->aCustomer = null; - } - if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) { - $this->aCustomerTitle = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AddressPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCustomer = null; - $this->aCustomerTitle = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AddressQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AddressPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AddressPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AddressPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AddressPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomer !== null) { - if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) { - $affectedRows += $this->aCustomer->save($con); - } - $this->setCustomer($this->aCustomer); - } - - if ($this->aCustomerTitle !== null) { - if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) { - $affectedRows += $this->aCustomerTitle->save($con); - } - $this->setCustomerTitle($this->aCustomerTitle); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AddressPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AddressPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AddressPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_id`'; - } - if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; - } - if ($this->isColumnModified(AddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; - } - if ($this->isColumnModified(AddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; - } - if ($this->isColumnModified(AddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; - } - if ($this->isColumnModified(AddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; - } - if ($this->isColumnModified(AddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; - } - if ($this->isColumnModified(AddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; - } - if ($this->isColumnModified(AddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; - } - if ($this->isColumnModified(AddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; - } - if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; - } - if ($this->isColumnModified(AddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; - } - if ($this->isColumnModified(AddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `address` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`customer_id`': - $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); - break; - case '`customer_title_id`': - $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); - break; - case '`company`': - $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); - break; - case '`firstname`': - $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); - break; - case '`lastname`': - $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); - break; - case '`address1`': - $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); - break; - case '`address2`': - $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); - break; - case '`address3`': - $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); - break; - case '`zipcode`': - $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); - break; - case '`city`': - $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); - break; - case '`country_id`': - $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); - break; - case '`phone`': - $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomer !== null) { - if (!$this->aCustomer->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures()); - } - } - - if ($this->aCustomerTitle !== null) { - if (!$this->aCustomerTitle->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures()); - } - } - - - if (($retval = AddressPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getTitle(); - break; - case 2: - return $this->getCustomerId(); - break; - case 3: - return $this->getCustomerTitleId(); - break; - case 4: - return $this->getCompany(); - break; - case 5: - return $this->getFirstname(); - break; - case 6: - return $this->getLastname(); - break; - case 7: - return $this->getAddress1(); - break; - case 8: - return $this->getAddress2(); - break; - case 9: - return $this->getAddress3(); - break; - case 10: - return $this->getZipcode(); - break; - case 11: - return $this->getCity(); - break; - case 12: - return $this->getCountryId(); - break; - case 13: - return $this->getPhone(); - break; - case 14: - return $this->getCreatedAt(); - break; - case 15: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Address'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Address'][$this->getPrimaryKey()] = true; - $keys = AddressPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getTitle(), - $keys[2] => $this->getCustomerId(), - $keys[3] => $this->getCustomerTitleId(), - $keys[4] => $this->getCompany(), - $keys[5] => $this->getFirstname(), - $keys[6] => $this->getLastname(), - $keys[7] => $this->getAddress1(), - $keys[8] => $this->getAddress2(), - $keys[9] => $this->getAddress3(), - $keys[10] => $this->getZipcode(), - $keys[11] => $this->getCity(), - $keys[12] => $this->getCountryId(), - $keys[13] => $this->getPhone(), - $keys[14] => $this->getCreatedAt(), - $keys[15] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCustomer) { - $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCustomerTitle) { - $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setTitle($value); - break; - case 2: - $this->setCustomerId($value); - break; - case 3: - $this->setCustomerTitleId($value); - break; - case 4: - $this->setCompany($value); - break; - case 5: - $this->setFirstname($value); - break; - case 6: - $this->setLastname($value); - break; - case 7: - $this->setAddress1($value); - break; - case 8: - $this->setAddress2($value); - break; - case 9: - $this->setAddress3($value); - break; - case 10: - $this->setZipcode($value); - break; - case 11: - $this->setCity($value); - break; - case 12: - $this->setCountryId($value); - break; - case 13: - $this->setPhone($value); - break; - case 14: - $this->setCreatedAt($value); - break; - case 15: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AddressPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCustomerTitleId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCompany($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setFirstname($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setLastname($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setAddress1($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setAddress2($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setAddress3($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setZipcode($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCity($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setCountryId($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setPhone($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setCreatedAt($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - - if ($this->isColumnModified(AddressPeer::ID)) $criteria->add(AddressPeer::ID, $this->id); - if ($this->isColumnModified(AddressPeer::TITLE)) $criteria->add(AddressPeer::TITLE, $this->title); - if ($this->isColumnModified(AddressPeer::CUSTOMER_ID)) $criteria->add(AddressPeer::CUSTOMER_ID, $this->customer_id); - if ($this->isColumnModified(AddressPeer::CUSTOMER_TITLE_ID)) $criteria->add(AddressPeer::CUSTOMER_TITLE_ID, $this->customer_title_id); - if ($this->isColumnModified(AddressPeer::COMPANY)) $criteria->add(AddressPeer::COMPANY, $this->company); - if ($this->isColumnModified(AddressPeer::FIRSTNAME)) $criteria->add(AddressPeer::FIRSTNAME, $this->firstname); - if ($this->isColumnModified(AddressPeer::LASTNAME)) $criteria->add(AddressPeer::LASTNAME, $this->lastname); - if ($this->isColumnModified(AddressPeer::ADDRESS1)) $criteria->add(AddressPeer::ADDRESS1, $this->address1); - if ($this->isColumnModified(AddressPeer::ADDRESS2)) $criteria->add(AddressPeer::ADDRESS2, $this->address2); - if ($this->isColumnModified(AddressPeer::ADDRESS3)) $criteria->add(AddressPeer::ADDRESS3, $this->address3); - if ($this->isColumnModified(AddressPeer::ZIPCODE)) $criteria->add(AddressPeer::ZIPCODE, $this->zipcode); - if ($this->isColumnModified(AddressPeer::CITY)) $criteria->add(AddressPeer::CITY, $this->city); - if ($this->isColumnModified(AddressPeer::COUNTRY_ID)) $criteria->add(AddressPeer::COUNTRY_ID, $this->country_id); - if ($this->isColumnModified(AddressPeer::PHONE)) $criteria->add(AddressPeer::PHONE, $this->phone); - if ($this->isColumnModified(AddressPeer::CREATED_AT)) $criteria->add(AddressPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AddressPeer::UPDATED_AT)) $criteria->add(AddressPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - $criteria->add(AddressPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Address (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setTitle($this->getTitle()); - $copyObj->setCustomerId($this->getCustomerId()); - $copyObj->setCustomerTitleId($this->getCustomerTitleId()); - $copyObj->setCompany($this->getCompany()); - $copyObj->setFirstname($this->getFirstname()); - $copyObj->setLastname($this->getLastname()); - $copyObj->setAddress1($this->getAddress1()); - $copyObj->setAddress2($this->getAddress2()); - $copyObj->setAddress3($this->getAddress3()); - $copyObj->setZipcode($this->getZipcode()); - $copyObj->setCity($this->getCity()); - $copyObj->setCountryId($this->getCountryId()); - $copyObj->setPhone($this->getPhone()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Address Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AddressPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AddressPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Customer object. - * - * @param Customer $v - * @return Address The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomer(Customer $v = null) - { - if ($v === null) { - $this->setCustomerId(NULL); - } else { - $this->setCustomerId($v->getId()); - } - - $this->aCustomer = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Customer object, it will not be re-added. - if ($v !== null) { - $v->addAddress($this); - } - - - return $this; - } - - - /** - * Get the associated Customer object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Customer The associated Customer object. - * @throws PropelException - */ - public function getCustomer(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { - $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomer->addAddresss($this); - */ - } - - return $this->aCustomer; - } - - /** - * Declares an association between this object and a CustomerTitle object. - * - * @param CustomerTitle $v - * @return Address The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomerTitle(CustomerTitle $v = null) - { - if ($v === null) { - $this->setCustomerTitleId(NULL); - } else { - $this->setCustomerTitleId($v->getId()); - } - - $this->aCustomerTitle = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CustomerTitle object, it will not be re-added. - if ($v !== null) { - $v->addAddress($this); - } - - - return $this; - } - - - /** - * Get the associated CustomerTitle object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CustomerTitle The associated CustomerTitle object. - * @throws PropelException - */ - public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { - $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomerTitle->addAddresss($this); - */ - } - - return $this->aCustomerTitle; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->title = null; - $this->customer_id = null; - $this->customer_title_id = null; - $this->company = null; - $this->firstname = null; - $this->lastname = null; - $this->address1 = null; - $this->address2 = null; - $this->address3 = null; - $this->zipcode = null; - $this->city = null; - $this->country_id = null; - $this->phone = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCustomer instanceof Persistent) { - $this->aCustomer->clearAllReferences($deep); - } - if ($this->aCustomerTitle instanceof Persistent) { - $this->aCustomerTitle->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCustomer = null; - $this->aCustomerTitle = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AddressPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Address The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AddressPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAddressPeer.php b/core/lib/Thelia/Model/om/BaseAddressPeer.php deleted file mode 100755 index 0c43808bc..000000000 --- a/core/lib/Thelia/Model/om/BaseAddressPeer.php +++ /dev/null @@ -1,1478 +0,0 @@ - array ('Id', 'Title', 'CustomerId', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'customerId', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AddressPeer::ID, AddressPeer::TITLE, AddressPeer::CUSTOMER_ID, AddressPeer::CUSTOMER_TITLE_ID, AddressPeer::COMPANY, AddressPeer::FIRSTNAME, AddressPeer::LASTNAME, AddressPeer::ADDRESS1, AddressPeer::ADDRESS2, AddressPeer::ADDRESS3, AddressPeer::ZIPCODE, AddressPeer::CITY, AddressPeer::COUNTRY_ID, AddressPeer::PHONE, AddressPeer::CREATED_AT, AddressPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CUSTOMER_ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'customer_id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AddressPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'CustomerId' => 2, 'CustomerTitleId' => 3, 'Company' => 4, 'Firstname' => 5, 'Lastname' => 6, 'Address1' => 7, 'Address2' => 8, 'Address3' => 9, 'Zipcode' => 10, 'City' => 11, 'CountryId' => 12, 'Phone' => 13, 'CreatedAt' => 14, 'UpdatedAt' => 15, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'customerId' => 2, 'customerTitleId' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'countryId' => 12, 'phone' => 13, 'createdAt' => 14, 'updatedAt' => 15, ), - BasePeer::TYPE_COLNAME => array (AddressPeer::ID => 0, AddressPeer::TITLE => 1, AddressPeer::CUSTOMER_ID => 2, AddressPeer::CUSTOMER_TITLE_ID => 3, AddressPeer::COMPANY => 4, AddressPeer::FIRSTNAME => 5, AddressPeer::LASTNAME => 6, AddressPeer::ADDRESS1 => 7, AddressPeer::ADDRESS2 => 8, AddressPeer::ADDRESS3 => 9, AddressPeer::ZIPCODE => 10, AddressPeer::CITY => 11, AddressPeer::COUNTRY_ID => 12, AddressPeer::PHONE => 13, AddressPeer::CREATED_AT => 14, AddressPeer::UPDATED_AT => 15, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CUSTOMER_ID' => 2, 'CUSTOMER_TITLE_ID' => 3, 'COMPANY' => 4, 'FIRSTNAME' => 5, 'LASTNAME' => 6, 'ADDRESS1' => 7, 'ADDRESS2' => 8, 'ADDRESS3' => 9, 'ZIPCODE' => 10, 'CITY' => 11, 'COUNTRY_ID' => 12, 'PHONE' => 13, 'CREATED_AT' => 14, 'UPDATED_AT' => 15, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'customer_id' => 2, 'customer_title_id' => 3, 'company' => 4, 'firstname' => 5, 'lastname' => 6, 'address1' => 7, 'address2' => 8, 'address3' => 9, 'zipcode' => 10, 'city' => 11, 'country_id' => 12, 'phone' => 13, 'created_at' => 14, 'updated_at' => 15, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AddressPeer::getFieldNames($toType); - $key = isset(AddressPeer::$fieldKeys[$fromType][$name]) ? AddressPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AddressPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AddressPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AddressPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AddressPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AddressPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AddressPeer::ID); - $criteria->addSelectColumn(AddressPeer::TITLE); - $criteria->addSelectColumn(AddressPeer::CUSTOMER_ID); - $criteria->addSelectColumn(AddressPeer::CUSTOMER_TITLE_ID); - $criteria->addSelectColumn(AddressPeer::COMPANY); - $criteria->addSelectColumn(AddressPeer::FIRSTNAME); - $criteria->addSelectColumn(AddressPeer::LASTNAME); - $criteria->addSelectColumn(AddressPeer::ADDRESS1); - $criteria->addSelectColumn(AddressPeer::ADDRESS2); - $criteria->addSelectColumn(AddressPeer::ADDRESS3); - $criteria->addSelectColumn(AddressPeer::ZIPCODE); - $criteria->addSelectColumn(AddressPeer::CITY); - $criteria->addSelectColumn(AddressPeer::COUNTRY_ID); - $criteria->addSelectColumn(AddressPeer::PHONE); - $criteria->addSelectColumn(AddressPeer::CREATED_AT); - $criteria->addSelectColumn(AddressPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.customer_id'); - $criteria->addSelectColumn($alias . '.customer_title_id'); - $criteria->addSelectColumn($alias . '.company'); - $criteria->addSelectColumn($alias . '.firstname'); - $criteria->addSelectColumn($alias . '.lastname'); - $criteria->addSelectColumn($alias . '.address1'); - $criteria->addSelectColumn($alias . '.address2'); - $criteria->addSelectColumn($alias . '.address3'); - $criteria->addSelectColumn($alias . '.zipcode'); - $criteria->addSelectColumn($alias . '.city'); - $criteria->addSelectColumn($alias . '.country_id'); - $criteria->addSelectColumn($alias . '.phone'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AddressPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Address - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AddressPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AddressPeer::populateObjects(AddressPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AddressPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Address $obj A Address object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AddressPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Address object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Address) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Address object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AddressPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Address Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AddressPeer::$instances[$key])) { - return AddressPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AddressPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AddressPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to address - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AddressPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AddressPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AddressPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Address object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AddressPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AddressPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AddressPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AddressPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AddressPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Customer table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related CustomerTitle table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Address objects pre-filled with their Customer objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Address objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AddressPeer::DATABASE_NAME); - } - - AddressPeer::addSelectColumns($criteria); - $startcol = AddressPeer::NUM_HYDRATE_COLUMNS; - CustomerPeer::addSelectColumns($criteria); - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AddressPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AddressPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CustomerPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CustomerPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Address) to $obj2 (Customer) - $obj2->addAddress($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Address objects pre-filled with their CustomerTitle objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Address objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AddressPeer::DATABASE_NAME); - } - - AddressPeer::addSelectColumns($criteria); - $startcol = AddressPeer::NUM_HYDRATE_COLUMNS; - CustomerTitlePeer::addSelectColumns($criteria); - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AddressPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AddressPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Address) to $obj2 (CustomerTitle) - $obj2->addAddress($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Address objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Address objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AddressPeer::DATABASE_NAME); - } - - AddressPeer::addSelectColumns($criteria); - $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - CustomerTitlePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AddressPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AddressPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Customer rows - - $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Address) to the collection in $obj2 (Customer) - $obj2->addAddress($obj1); - } // if joined row not null - - // Add objects for joined CustomerTitle rows - - $key3 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CustomerTitlePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CustomerTitlePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Address) to the collection in $obj3 (CustomerTitle) - $obj3->addAddress($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Customer table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related CustomerTitle table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Address objects pre-filled with all related objects except Customer. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Address objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AddressPeer::DATABASE_NAME); - } - - AddressPeer::addSelectColumns($criteria); - $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS; - - CustomerTitlePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AddressPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AddressPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AddressPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CustomerTitle rows - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Address) to the collection in $obj2 (CustomerTitle) - $obj2->addAddress($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Address objects pre-filled with all related objects except CustomerTitle. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Address objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AddressPeer::DATABASE_NAME); - } - - AddressPeer::addSelectColumns($criteria); - $startcol2 = AddressPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AddressPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AddressPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AddressPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AddressPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Customer rows - - $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Address) to the collection in $obj2 (Customer) - $obj2->addAddress($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AddressPeer::DATABASE_NAME)->getTable(AddressPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAddressPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAddressPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AddressTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AddressPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Address or Criteria object. - * - * @param mixed $values Criteria or Address object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Address object - } - - if ($criteria->containsKey(AddressPeer::ID) && $criteria->keyContainsValue(AddressPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AddressPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Address or Criteria object. - * - * @param mixed $values Criteria or Address object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AddressPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AddressPeer::ID); - $value = $criteria->remove(AddressPeer::ID); - if ($value) { - $selectCriteria->add(AddressPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AddressPeer::TABLE_NAME); - } - - } else { // $values is Address object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the address table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AddressPeer::TABLE_NAME, $con, AddressPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AddressPeer::clearInstancePool(); - AddressPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Address or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Address object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AddressPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Address) { // it's a model object - // invalidate the cache for this single object - AddressPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - $criteria->add(AddressPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AddressPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AddressPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AddressPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Address object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Address $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AddressPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AddressPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AddressPeer::DATABASE_NAME, AddressPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Address - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AddressPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - $criteria->add(AddressPeer::ID, $pk); - - $v = AddressPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Address[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AddressPeer::DATABASE_NAME); - $criteria->add(AddressPeer::ID, $pks, Criteria::IN); - $objs = AddressPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAddressPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAddressPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAddressQuery.php b/core/lib/Thelia/Model/om/BaseAddressQuery.php deleted file mode 100755 index 46b6e5146..000000000 --- a/core/lib/Thelia/Model/om/BaseAddressQuery.php +++ /dev/null @@ -1,1080 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Address|Address[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AddressPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Address A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Address A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `title`, `customer_id`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `country_id`, `phone`, `created_at`, `updated_at` FROM `address` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Address(); - $obj->hydrate($row); - AddressPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Address|Address[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Address[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AddressPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AddressPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AddressPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the customer_id column - * - * Example usage: - * - * $query->filterByCustomerId(1234); // WHERE customer_id = 1234 - * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34) - * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12 - * $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12 - * - * - * @see filterByCustomer() - * - * @param mixed $customerId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCustomerId($customerId = null, $comparison = null) - { - if (is_array($customerId)) { - $useMinMax = false; - if (isset($customerId['min'])) { - $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerId['max'])) { - $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::CUSTOMER_ID, $customerId, $comparison); - } - - /** - * Filter the query on the customer_title_id column - * - * Example usage: - * - * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 - * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 - * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 - * - * - * @see filterByCustomerTitle() - * - * @param mixed $customerTitleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCustomerTitleId($customerTitleId = null, $comparison = null) - { - if (is_array($customerTitleId)) { - $useMinMax = false; - if (isset($customerTitleId['min'])) { - $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerTitleId['max'])) { - $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); - } - - /** - * Filter the query on the company column - * - * Example usage: - * - * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue' - * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%' - * - * - * @param string $company The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCompany($company = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($company)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $company)) { - $company = str_replace('*', '%', $company); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::COMPANY, $company, $comparison); - } - - /** - * Filter the query on the firstname column - * - * Example usage: - * - * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue' - * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%' - * - * - * @param string $firstname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByFirstname($firstname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($firstname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $firstname)) { - $firstname = str_replace('*', '%', $firstname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::FIRSTNAME, $firstname, $comparison); - } - - /** - * Filter the query on the lastname column - * - * Example usage: - * - * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue' - * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%' - * - * - * @param string $lastname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByLastname($lastname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lastname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lastname)) { - $lastname = str_replace('*', '%', $lastname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::LASTNAME, $lastname, $comparison); - } - - /** - * Filter the query on the address1 column - * - * Example usage: - * - * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue' - * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%' - * - * - * @param string $address1 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByAddress1($address1 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address1)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address1)) { - $address1 = str_replace('*', '%', $address1); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::ADDRESS1, $address1, $comparison); - } - - /** - * Filter the query on the address2 column - * - * Example usage: - * - * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue' - * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%' - * - * - * @param string $address2 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByAddress2($address2 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address2)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address2)) { - $address2 = str_replace('*', '%', $address2); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::ADDRESS2, $address2, $comparison); - } - - /** - * Filter the query on the address3 column - * - * Example usage: - * - * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue' - * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%' - * - * - * @param string $address3 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByAddress3($address3 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address3)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address3)) { - $address3 = str_replace('*', '%', $address3); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::ADDRESS3, $address3, $comparison); - } - - /** - * Filter the query on the zipcode column - * - * Example usage: - * - * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue' - * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%' - * - * - * @param string $zipcode The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByZipcode($zipcode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($zipcode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $zipcode)) { - $zipcode = str_replace('*', '%', $zipcode); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::ZIPCODE, $zipcode, $comparison); - } - - /** - * Filter the query on the city column - * - * Example usage: - * - * $query->filterByCity('fooValue'); // WHERE city = 'fooValue' - * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%' - * - * - * @param string $city The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCity($city = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($city)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $city)) { - $city = str_replace('*', '%', $city); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::CITY, $city, $comparison); - } - - /** - * Filter the query on the country_id column - * - * Example usage: - * - * $query->filterByCountryId(1234); // WHERE country_id = 1234 - * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 - * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 - * - * - * @param mixed $countryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCountryId($countryId = null, $comparison = null) - { - if (is_array($countryId)) { - $useMinMax = false; - if (isset($countryId['min'])) { - $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($countryId['max'])) { - $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::COUNTRY_ID, $countryId, $comparison); - } - - /** - * Filter the query on the phone column - * - * Example usage: - * - * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue' - * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%' - * - * - * @param string $phone The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByPhone($phone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($phone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $phone)) { - $phone = str_replace('*', '%', $phone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AddressPeer::PHONE, $phone, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AddressPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Customer object - * - * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomer($customer, $comparison = null) - { - if ($customer instanceof Customer) { - return $this - ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->getId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AddressPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Customer relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AddressQuery The current query, for fluid interface - */ - public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Customer'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Customer'); - } - - return $this; - } - - /** - * Use the Customer relation Customer object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query - */ - public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCustomer($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); - } - - /** - * Filter the query by a related CustomerTitle object - * - * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomerTitle($customerTitle, $comparison = null) - { - if ($customerTitle instanceof CustomerTitle) { - return $this - ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AddressPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CustomerTitle relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AddressQuery The current query, for fluid interface - */ - public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CustomerTitle'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CustomerTitle'); - } - - return $this; - } - - /** - * Use the CustomerTitle relation CustomerTitle object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query - */ - public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCustomerTitle($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); - } - - /** - * Exclude object from result - * - * @param Address $address Object to remove from the list of results - * - * @return AddressQuery The current query, for fluid interface - */ - public function prune($address = null) - { - if ($address) { - $this->addUsingAlias(AddressPeer::ID, $address->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AddressQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AddressPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AddressQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AddressPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AddressQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AddressPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AddressQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AddressPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AddressQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AddressPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AddressQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AddressPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAdmin.php b/core/lib/Thelia/Model/om/BaseAdmin.php deleted file mode 100755 index 5bf15b3ff..000000000 --- a/core/lib/Thelia/Model/om/BaseAdmin.php +++ /dev/null @@ -1,1868 +0,0 @@ -id; - } - - /** - * Get the [firstname] column value. - * - * @return string - */ - public function getFirstname() - { - return $this->firstname; - } - - /** - * Get the [lastname] column value. - * - * @return string - */ - public function getLastname() - { - return $this->lastname; - } - - /** - * Get the [login] column value. - * - * @return string - */ - public function getLogin() - { - return $this->login; - } - - /** - * Get the [password] column value. - * - * @return string - */ - public function getPassword() - { - return $this->password; - } - - /** - * Get the [algo] column value. - * - * @return string - */ - public function getAlgo() - { - return $this->algo; - } - - /** - * Get the [salt] column value. - * - * @return string - */ - public function getSalt() - { - return $this->salt; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Admin The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AdminPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [firstname] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setFirstname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->firstname !== $v) { - $this->firstname = $v; - $this->modifiedColumns[] = AdminPeer::FIRSTNAME; - } - - - return $this; - } // setFirstname() - - /** - * Set the value of [lastname] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setLastname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lastname !== $v) { - $this->lastname = $v; - $this->modifiedColumns[] = AdminPeer::LASTNAME; - } - - - return $this; - } // setLastname() - - /** - * Set the value of [login] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setLogin($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->login !== $v) { - $this->login = $v; - $this->modifiedColumns[] = AdminPeer::LOGIN; - } - - - return $this; - } // setLogin() - - /** - * Set the value of [password] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setPassword($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->password !== $v) { - $this->password = $v; - $this->modifiedColumns[] = AdminPeer::PASSWORD; - } - - - return $this; - } // setPassword() - - /** - * Set the value of [algo] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setAlgo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->algo !== $v) { - $this->algo = $v; - $this->modifiedColumns[] = AdminPeer::ALGO; - } - - - return $this; - } // setAlgo() - - /** - * Set the value of [salt] column. - * - * @param string $v new value - * @return Admin The current object (for fluent API support) - */ - public function setSalt($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->salt !== $v) { - $this->salt = $v; - $this->modifiedColumns[] = AdminPeer::SALT; - } - - - return $this; - } // setSalt() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Admin The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AdminPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Admin The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AdminPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->firstname = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->lastname = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->login = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->password = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->algo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->salt = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = AdminPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Admin object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AdminPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAdminGroups = null; - - $this->collGroups = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AdminQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AdminPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AdminPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AdminPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AdminPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->groupsScheduledForDeletion !== null) { - if (!$this->groupsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - AdminGroupQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->groupsScheduledForDeletion = null; - } - - foreach ($this->getGroups() as $group) { - if ($group->isModified()) { - $group->save($con); - } - } - } elseif ($this->collGroups) { - foreach ($this->collGroups as $group) { - if ($group->isModified()) { - $group->save($con); - } - } - } - - if ($this->adminGroupsScheduledForDeletion !== null) { - if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - AdminGroupQuery::create() - ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->adminGroupsScheduledForDeletion = null; - } - } - - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AdminPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AdminPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AdminPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; - } - if ($this->isColumnModified(AdminPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; - } - if ($this->isColumnModified(AdminPeer::LOGIN)) { - $modifiedColumns[':p' . $index++] = '`login`'; - } - if ($this->isColumnModified(AdminPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`password`'; - } - if ($this->isColumnModified(AdminPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`algo`'; - } - if ($this->isColumnModified(AdminPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`salt`'; - } - if ($this->isColumnModified(AdminPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AdminPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `admin` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`firstname`': - $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); - break; - case '`lastname`': - $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); - break; - case '`login`': - $stmt->bindValue($identifier, $this->login, PDO::PARAM_STR); - break; - case '`password`': - $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); - break; - case '`algo`': - $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); - break; - case '`salt`': - $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = AdminPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getFirstname(); - break; - case 2: - return $this->getLastname(); - break; - case 3: - return $this->getLogin(); - break; - case 4: - return $this->getPassword(); - break; - case 5: - return $this->getAlgo(); - break; - case 6: - return $this->getSalt(); - break; - case 7: - return $this->getCreatedAt(); - break; - case 8: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Admin'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Admin'][$this->getPrimaryKey()] = true; - $keys = AdminPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getFirstname(), - $keys[2] => $this->getLastname(), - $keys[3] => $this->getLogin(), - $keys[4] => $this->getPassword(), - $keys[5] => $this->getAlgo(), - $keys[6] => $this->getSalt(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collAdminGroups) { - $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setFirstname($value); - break; - case 2: - $this->setLastname($value); - break; - case 3: - $this->setLogin($value); - break; - case 4: - $this->setPassword($value); - break; - case 5: - $this->setAlgo($value); - break; - case 6: - $this->setSalt($value); - break; - case 7: - $this->setCreatedAt($value); - break; - case 8: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AdminPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setFirstname($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setLastname($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setLogin($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPassword($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAlgo($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setSalt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - - if ($this->isColumnModified(AdminPeer::ID)) $criteria->add(AdminPeer::ID, $this->id); - if ($this->isColumnModified(AdminPeer::FIRSTNAME)) $criteria->add(AdminPeer::FIRSTNAME, $this->firstname); - if ($this->isColumnModified(AdminPeer::LASTNAME)) $criteria->add(AdminPeer::LASTNAME, $this->lastname); - if ($this->isColumnModified(AdminPeer::LOGIN)) $criteria->add(AdminPeer::LOGIN, $this->login); - if ($this->isColumnModified(AdminPeer::PASSWORD)) $criteria->add(AdminPeer::PASSWORD, $this->password); - if ($this->isColumnModified(AdminPeer::ALGO)) $criteria->add(AdminPeer::ALGO, $this->algo); - if ($this->isColumnModified(AdminPeer::SALT)) $criteria->add(AdminPeer::SALT, $this->salt); - if ($this->isColumnModified(AdminPeer::CREATED_AT)) $criteria->add(AdminPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AdminPeer::UPDATED_AT)) $criteria->add(AdminPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - $criteria->add(AdminPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Admin (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setFirstname($this->getFirstname()); - $copyObj->setLastname($this->getLastname()); - $copyObj->setLogin($this->getLogin()); - $copyObj->setPassword($this->getPassword()); - $copyObj->setAlgo($this->getAlgo()); - $copyObj->setSalt($this->getSalt()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAdminGroups() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAdminGroup($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Admin Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AdminPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AdminPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AdminGroup' == $relationName) { - $this->initAdminGroups(); - } - } - - /** - * Clears out the collAdminGroups collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Admin The current object (for fluent API support) - * @see addAdminGroups() - */ - public function clearAdminGroups() - { - $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized - $this->collAdminGroupsPartial = null; - - return $this; - } - - /** - * reset is the collAdminGroups collection loaded partially - * - * @return void - */ - public function resetPartialAdminGroups($v = true) - { - $this->collAdminGroupsPartial = $v; - } - - /** - * Initializes the collAdminGroups collection. - * - * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAdminGroups($overrideExisting = true) - { - if (null !== $this->collAdminGroups && !$overrideExisting) { - return; - } - $this->collAdminGroups = new PropelObjectCollection(); - $this->collAdminGroups->setModel('AdminGroup'); - } - - /** - * Gets an array of AdminGroup objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Admin is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects - * @throws PropelException - */ - public function getAdminGroups($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - // return empty collection - $this->initAdminGroups(); - } else { - $collAdminGroups = AdminGroupQuery::create(null, $criteria) - ->filterByAdmin($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); - - foreach($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); - } - } - - $this->collAdminGroupsPartial = true; - } - - $collAdminGroups->getInternalIterator()->rewind(); - return $collAdminGroups; - } - - if($partial && $this->collAdminGroups) { - foreach($this->collAdminGroups as $obj) { - if($obj->isNew()) { - $collAdminGroups[] = $obj; - } - } - } - - $this->collAdminGroups = $collAdminGroups; - $this->collAdminGroupsPartial = false; - } - } - - return $this->collAdminGroups; - } - - /** - * Sets a collection of AdminGroup objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $adminGroups A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Admin The current object (for fluent API support) - */ - public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) - { - $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - - $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); - - foreach ($adminGroupsToDelete as $adminGroupRemoved) { - $adminGroupRemoved->setAdmin(null); - } - - $this->collAdminGroups = null; - foreach ($adminGroups as $adminGroup) { - $this->addAdminGroup($adminGroup); - } - - $this->collAdminGroups = $adminGroups; - $this->collAdminGroupsPartial = false; - - return $this; - } - - /** - * Returns the number of related AdminGroup objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AdminGroup objects. - * @throws PropelException - */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAdminGroups()); - } - $query = AdminGroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAdmin($this) - ->count($con); - } - - return count($this->collAdminGroups); - } - - /** - * Method called to associate a AdminGroup object to this object - * through the AdminGroup foreign key attribute. - * - * @param AdminGroup $l AdminGroup - * @return Admin The current object (for fluent API support) - */ - public function addAdminGroup(AdminGroup $l) - { - if ($this->collAdminGroups === null) { - $this->initAdminGroups(); - $this->collAdminGroupsPartial = true; - } - if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAdminGroup($l); - } - - return $this; - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to add. - */ - protected function doAddAdminGroup($adminGroup) - { - $this->collAdminGroups[]= $adminGroup; - $adminGroup->setAdmin($this); - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to remove. - * @return Admin The current object (for fluent API support) - */ - public function removeAdminGroup($adminGroup) - { - if ($this->getAdminGroups()->contains($adminGroup)) { - $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup)); - if (null === $this->adminGroupsScheduledForDeletion) { - $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups; - $this->adminGroupsScheduledForDeletion->clear(); - } - $this->adminGroupsScheduledForDeletion[]= clone $adminGroup; - $adminGroup->setAdmin(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Admin is new, it will return - * an empty collection; or if this Admin has previously - * been saved, it will retrieve related AdminGroups from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Admin. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects - */ - public function getAdminGroupsJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AdminGroupQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); - - return $this->getAdminGroups($query, $con); - } - - /** - * Clears out the collGroups 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 Admin The current object (for fluent API support) - * @see addGroups() - */ - public function clearGroups() - { - $this->collGroups = null; // important to set this to null since that means it is uninitialized - $this->collGroupsPartial = null; - - return $this; - } - - /** - * Initializes the collGroups collection. - * - * By default this just sets the collGroups collection to an empty collection (like clearGroups()); - * 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. - * - * @return void - */ - public function initGroups() - { - $this->collGroups = new PropelObjectCollection(); - $this->collGroups->setModel('Group'); - } - - /** - * Gets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Admin is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Group[] List of Group objects - */ - public function getGroups($criteria = null, PropelPDO $con = null) - { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { - // return empty collection - $this->initGroups(); - } else { - $collGroups = GroupQuery::create(null, $criteria) - ->filterByAdmin($this) - ->find($con); - if (null !== $criteria) { - return $collGroups; - } - $this->collGroups = $collGroups; - } - } - - return $this->collGroups; - } - - /** - * Sets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * 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 $groups A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Admin The current object (for fluent API support) - */ - public function setGroups(PropelCollection $groups, PropelPDO $con = null) - { - $this->clearGroups(); - $currentGroups = $this->getGroups(); - - $this->groupsScheduledForDeletion = $currentGroups->diff($groups); - - foreach ($groups as $group) { - if (!$currentGroups->contains($group)) { - $this->doAddGroup($group); - } - } - - $this->collGroups = $groups; - - return $this; - } - - /** - * Gets the number of Group objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Group objects - */ - public function countGroups($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { - return 0; - } else { - $query = GroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAdmin($this) - ->count($con); - } - } else { - return count($this->collGroups); - } - } - - /** - * Associate a Group object to this object - * through the admin_group cross reference table. - * - * @param Group $group The AdminGroup object to relate - * @return Admin The current object (for fluent API support) - */ - public function addGroup(Group $group) - { - if ($this->collGroups === null) { - $this->initGroups(); - } - if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated - $this->doAddGroup($group); - - $this->collGroups[]= $group; - } - - return $this; - } - - /** - * @param Group $group The group object to add. - */ - protected function doAddGroup($group) - { - $adminGroup = new AdminGroup(); - $adminGroup->setGroup($group); - $this->addAdminGroup($adminGroup); - } - - /** - * Remove a Group object to this object - * through the admin_group cross reference table. - * - * @param Group $group The AdminGroup object to relate - * @return Admin The current object (for fluent API support) - */ - public function removeGroup(Group $group) - { - if ($this->getGroups()->contains($group)) { - $this->collGroups->remove($this->collGroups->search($group)); - if (null === $this->groupsScheduledForDeletion) { - $this->groupsScheduledForDeletion = clone $this->collGroups; - $this->groupsScheduledForDeletion->clear(); - } - $this->groupsScheduledForDeletion[]= $group; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->firstname = null; - $this->lastname = null; - $this->login = null; - $this->password = null; - $this->algo = null; - $this->salt = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAdminGroups) { - foreach ($this->collAdminGroups as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroups) { - foreach ($this->collGroups as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collAdminGroups instanceof PropelCollection) { - $this->collAdminGroups->clearIterator(); - } - $this->collAdminGroups = null; - if ($this->collGroups instanceof PropelCollection) { - $this->collGroups->clearIterator(); - } - $this->collGroups = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AdminPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Admin The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AdminPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAdminGroup.php b/core/lib/Thelia/Model/om/BaseAdminGroup.php deleted file mode 100755 index 98b15fc14..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminGroup.php +++ /dev/null @@ -1,1297 +0,0 @@ -id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - return $this->group_id; - } - - /** - * Get the [admin_id] column value. - * - * @return int - */ - public function getAdminId() - { - return $this->admin_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AdminGroup The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AdminGroupPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return AdminGroup The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = AdminGroupPeer::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [admin_id] column. - * - * @param int $v new value - * @return AdminGroup The current object (for fluent API support) - */ - public function setAdminId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->admin_id !== $v) { - $this->admin_id = $v; - $this->modifiedColumns[] = AdminGroupPeer::ADMIN_ID; - } - - if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) { - $this->aAdmin = null; - } - - - return $this; - } // setAdminId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AdminGroup The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AdminGroupPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AdminGroup The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AdminGroupPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->admin_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = AdminGroupPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AdminGroup object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) { - $this->aAdmin = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AdminGroupPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aAdmin = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AdminGroupQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AdminGroupPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AdminGroupPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aAdmin !== null) { - if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) { - $affectedRows += $this->aAdmin->save($con); - } - $this->setAdmin($this->aAdmin); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AdminGroupPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminGroupPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AdminGroupPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AdminGroupPeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`group_id`'; - } - if ($this->isColumnModified(AdminGroupPeer::ADMIN_ID)) { - $modifiedColumns[':p' . $index++] = '`admin_id`'; - } - if ($this->isColumnModified(AdminGroupPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AdminGroupPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `admin_group` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`group_id`': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case '`admin_id`': - $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if (!$this->aGroup->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures()); - } - } - - if ($this->aAdmin !== null) { - if (!$this->aAdmin->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAdmin->getValidationFailures()); - } - } - - - if (($retval = AdminGroupPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getAdminId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())] = true; - $keys = AdminGroupPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getAdminId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aAdmin) { - $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminGroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setAdminId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AdminGroupPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME); - - if ($this->isColumnModified(AdminGroupPeer::ID)) $criteria->add(AdminGroupPeer::ID, $this->id); - if ($this->isColumnModified(AdminGroupPeer::GROUP_ID)) $criteria->add(AdminGroupPeer::GROUP_ID, $this->group_id); - if ($this->isColumnModified(AdminGroupPeer::ADMIN_ID)) $criteria->add(AdminGroupPeer::ADMIN_ID, $this->admin_id); - if ($this->isColumnModified(AdminGroupPeer::CREATED_AT)) $criteria->add(AdminGroupPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AdminGroupPeer::UPDATED_AT)) $criteria->add(AdminGroupPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME); - $criteria->add(AdminGroupPeer::ID, $this->id); - $criteria->add(AdminGroupPeer::GROUP_ID, $this->group_id); - $criteria->add(AdminGroupPeer::ADMIN_ID, $this->admin_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getGroupId(); - $pks[2] = $this->getAdminId(); - - 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->setGroupId($keys[1]); - $this->setAdminId($keys[2]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getAdminId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of AdminGroup (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setAdminId($this->getAdminId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return AdminGroup Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AdminGroupPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AdminGroupPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Group object. - * - * @param Group $v - * @return AdminGroup The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(Group $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Group object, it will not be re-added. - if ($v !== null) { - $v->addAdminGroup($this); - } - - - return $this; - } - - - /** - * Get the associated Group object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Group The associated Group object. - * @throws PropelException - */ - public function getGroup(PropelPDO $con = null, $doQuery = true) - { - if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { - $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addAdminGroups($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a Admin object. - * - * @param Admin $v - * @return AdminGroup The current object (for fluent API support) - * @throws PropelException - */ - public function setAdmin(Admin $v = null) - { - if ($v === null) { - $this->setAdminId(NULL); - } else { - $this->setAdminId($v->getId()); - } - - $this->aAdmin = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Admin object, it will not be re-added. - if ($v !== null) { - $v->addAdminGroup($this); - } - - - return $this; - } - - - /** - * Get the associated Admin object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Admin The associated Admin object. - * @throws PropelException - */ - public function getAdmin(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAdmin === null && ($this->admin_id !== null) && $doQuery) { - $this->aAdmin = AdminQuery::create()->findPk($this->admin_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAdmin->addAdminGroups($this); - */ - } - - return $this->aAdmin; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->admin_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aGroup instanceof Persistent) { - $this->aGroup->clearAllReferences($deep); - } - if ($this->aAdmin instanceof Persistent) { - $this->aAdmin->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aGroup = null; - $this->aAdmin = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AdminGroupPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return AdminGroup The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AdminGroupPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php b/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php deleted file mode 100755 index 42819d8f3..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminGroupPeer.php +++ /dev/null @@ -1,1420 +0,0 @@ - array ('Id', 'GroupId', 'AdminId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'adminId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AdminGroupPeer::ID, AdminGroupPeer::GROUP_ID, AdminGroupPeer::ADMIN_ID, AdminGroupPeer::CREATED_AT, AdminGroupPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'admin_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AdminGroupPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (AdminGroupPeer::ID => 0, AdminGroupPeer::GROUP_ID => 1, AdminGroupPeer::ADMIN_ID => 2, AdminGroupPeer::CREATED_AT => 3, AdminGroupPeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AdminGroupPeer::getFieldNames($toType); - $key = isset(AdminGroupPeer::$fieldKeys[$fromType][$name]) ? AdminGroupPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminGroupPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AdminGroupPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AdminGroupPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AdminGroupPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AdminGroupPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AdminGroupPeer::ID); - $criteria->addSelectColumn(AdminGroupPeer::GROUP_ID); - $criteria->addSelectColumn(AdminGroupPeer::ADMIN_ID); - $criteria->addSelectColumn(AdminGroupPeer::CREATED_AT); - $criteria->addSelectColumn(AdminGroupPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.group_id'); - $criteria->addSelectColumn($alias . '.admin_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return AdminGroup - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AdminGroupPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AdminGroupPeer::populateObjects(AdminGroupPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AdminGroupPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param AdminGroup $obj A AdminGroup object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getAdminId())); - } // if key === null - AdminGroupPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A AdminGroup object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof AdminGroup) { - $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getAdminId())); - } elseif (is_array($value) && count($value) === 3) { - // assume we've been passed a primary key - $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AdminGroup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AdminGroupPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return AdminGroup Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AdminGroupPeer::$instances[$key])) { - return AdminGroupPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AdminGroupPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AdminGroupPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to admin_group - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null && $row[$startcol + 2] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1], (string) $row[$startcol + 2])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (int) $row[$startcol + 1], (int) $row[$startcol + 2]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AdminGroupPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AdminGroupPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AdminGroupPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AdminGroup object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AdminGroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AdminGroupPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AdminGroupPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AdminGroupPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AdminGroupPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Admin table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAdmin(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AdminGroup objects pre-filled with their Group objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AdminGroup objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - } - - AdminGroupPeer::addSelectColumns($criteria); - $startcol = AdminGroupPeer::NUM_HYDRATE_COLUMNS; - GroupPeer::addSelectColumns($criteria); - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AdminGroupPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AdminGroup) to $obj2 (Group) - $obj2->addAdminGroup($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AdminGroup objects pre-filled with their Admin objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AdminGroup objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAdmin(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - } - - AdminGroupPeer::addSelectColumns($criteria); - $startcol = AdminGroupPeer::NUM_HYDRATE_COLUMNS; - AdminPeer::addSelectColumns($criteria); - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AdminGroupPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AdminPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AdminPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AdminPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AdminGroup) to $obj2 (Admin) - $obj2->addAdminGroup($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AdminGroup objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AdminGroup objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - } - - AdminGroupPeer::addSelectColumns($criteria); - $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - AdminPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + AdminPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AdminGroupPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AdminGroup) to the collection in $obj2 (Group) - $obj2->addAdminGroup($obj1); - } // if joined row not null - - // Add objects for joined Admin rows - - $key3 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = AdminPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = AdminPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - AdminPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (AdminGroup) to the collection in $obj3 (Admin) - $obj3->addAdminGroup($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Admin table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptAdmin(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminGroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AdminGroup objects pre-filled with all related objects except Group. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AdminGroup objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - } - - AdminGroupPeer::addSelectColumns($criteria); - $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS; - - AdminPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AdminPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AdminGroupPeer::ADMIN_ID, AdminPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AdminGroupPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Admin rows - - $key2 = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AdminPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AdminPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AdminPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AdminGroup) to the collection in $obj2 (Admin) - $obj2->addAdminGroup($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AdminGroup objects pre-filled with all related objects except Admin. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AdminGroup objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptAdmin(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - } - - AdminGroupPeer::addSelectColumns($criteria); - $startcol2 = AdminGroupPeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AdminGroupPeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AdminGroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AdminGroupPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AdminGroupPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AdminGroup) to the collection in $obj2 (Group) - $obj2->addAdminGroup($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AdminGroupPeer::DATABASE_NAME)->getTable(AdminGroupPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAdminGroupPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAdminGroupPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AdminGroupTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AdminGroupPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AdminGroup or Criteria object. - * - * @param mixed $values Criteria or AdminGroup object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AdminGroup object - } - - if ($criteria->containsKey(AdminGroupPeer::ID) && $criteria->keyContainsValue(AdminGroupPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminGroupPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a AdminGroup or Criteria object. - * - * @param mixed $values Criteria or AdminGroup object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AdminGroupPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AdminGroupPeer::ID); - $value = $criteria->remove(AdminGroupPeer::ID); - if ($value) { - $selectCriteria->add(AdminGroupPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AdminGroupPeer::GROUP_ID); - $value = $criteria->remove(AdminGroupPeer::GROUP_ID); - if ($value) { - $selectCriteria->add(AdminGroupPeer::GROUP_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AdminGroupPeer::ADMIN_ID); - $value = $criteria->remove(AdminGroupPeer::ADMIN_ID); - if ($value) { - $selectCriteria->add(AdminGroupPeer::ADMIN_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AdminGroupPeer::TABLE_NAME); - } - - } else { // $values is AdminGroup object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the admin_group table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AdminGroupPeer::TABLE_NAME, $con, AdminGroupPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AdminGroupPeer::clearInstancePool(); - AdminGroupPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AdminGroup or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AdminGroup object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AdminGroupPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AdminGroup) { // it's a model object - // invalidate the cache for this single object - AdminGroupPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME); - // 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(AdminGroupPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(AdminGroupPeer::GROUP_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(AdminGroupPeer::ADMIN_ID, $value[2])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - AdminGroupPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(AdminGroupPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AdminGroupPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AdminGroup object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param AdminGroup $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AdminGroupPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AdminGroupPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AdminGroupPeer::DATABASE_NAME, AdminGroupPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param int $group_id - * @param int $admin_id - * @param PropelPDO $con - * @return AdminGroup - */ - public static function retrieveByPK($id, $group_id, $admin_id, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $group_id, (string) $admin_id)); - if (null !== ($obj = AdminGroupPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(AdminGroupPeer::DATABASE_NAME); - $criteria->add(AdminGroupPeer::ID, $id); - $criteria->add(AdminGroupPeer::GROUP_ID, $group_id); - $criteria->add(AdminGroupPeer::ADMIN_ID, $admin_id); - $v = AdminGroupPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseAdminGroupPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAdminGroupPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php b/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php deleted file mode 100755 index fa37ae6f6..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminGroupQuery.php +++ /dev/null @@ -1,711 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34, 56), $con); - * - * - * @param array $key Primary key to use for the query - A Primary key composition: [$id, $group_id, $admin_id] - * @param PropelPDO $con an optional connection object - * - * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AdminGroupPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AdminGroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AdminGroup A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `group_id`, `admin_id`, `created_at`, `updated_at` FROM `admin_group` WHERE `id` = :p0 AND `group_id` = :p1 AND `admin_id` = :p2'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AdminGroup(); - $obj->hydrate($row); - AdminGroupPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AdminGroup|AdminGroup[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(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|AdminGroup[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(AdminGroupPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $key[2], 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 AdminGroupQuery 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(AdminGroupPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(AdminGroupPeer::GROUP_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AdminGroupPeer::ADMIN_ID, $key[2], Criteria::EQUAL); - $cton0->addAnd($cton2); - $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AdminGroupPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AdminGroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 - * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupPeer::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the admin_id column - * - * Example usage: - * - * $query->filterByAdminId(1234); // WHERE admin_id = 1234 - * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34) - * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id >= 12 - * $query->filterByAdminId(array('max' => 12)); // WHERE admin_id <= 12 - * - * - * @see filterByAdmin() - * - * @param mixed $adminId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterByAdminId($adminId = null, $comparison = null) - { - if (is_array($adminId)) { - $useMinMax = false; - if (isset($adminId['min'])) { - $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($adminId['max'])) { - $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupPeer::ADMIN_ID, $adminId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Group object - * - * @param Group|PropelObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof Group) { - return $this - ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AdminGroupPeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related Admin object - * - * @param Admin|PropelObjectCollection $admin The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminGroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAdmin($admin, $comparison = null) - { - if ($admin instanceof Admin) { - return $this - ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->getId(), $comparison); - } elseif ($admin instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AdminGroupPeer::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAdmin() only accepts arguments of type Admin or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Admin relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Admin'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Admin'); - } - - return $this; - } - - /** - * Use the Admin relation Admin object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query - */ - public function useAdminQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAdmin($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery'); - } - - /** - * Exclude object from result - * - * @param AdminGroup $adminGroup Object to remove from the list of results - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function prune($adminGroup = null) - { - if ($adminGroup) { - $this->addCond('pruneCond0', $this->getAliasedColName(AdminGroupPeer::ID), $adminGroup->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(AdminGroupPeer::GROUP_ID), $adminGroup->getGroupId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(AdminGroupPeer::ADMIN_ID), $adminGroup->getAdminId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AdminGroupPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AdminGroupPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AdminGroupPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AdminGroupPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AdminGroupPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AdminGroupQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AdminGroupPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAdminLog.php b/core/lib/Thelia/Model/om/BaseAdminLog.php deleted file mode 100755 index 3ce64369b..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminLog.php +++ /dev/null @@ -1,1252 +0,0 @@ -id; - } - - /** - * Get the [admin_login] column value. - * - * @return string - */ - public function getAdminLogin() - { - return $this->admin_login; - } - - /** - * Get the [admin_firstname] column value. - * - * @return string - */ - public function getAdminFirstname() - { - return $this->admin_firstname; - } - - /** - * Get the [admin_lastname] column value. - * - * @return string - */ - public function getAdminLastname() - { - return $this->admin_lastname; - } - - /** - * Get the [action] column value. - * - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * Get the [request] column value. - * - * @return string - */ - public function getRequest() - { - return $this->request; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AdminLogPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [admin_login] column. - * - * @param string $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setAdminLogin($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->admin_login !== $v) { - $this->admin_login = $v; - $this->modifiedColumns[] = AdminLogPeer::ADMIN_LOGIN; - } - - - return $this; - } // setAdminLogin() - - /** - * Set the value of [admin_firstname] column. - * - * @param string $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setAdminFirstname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->admin_firstname !== $v) { - $this->admin_firstname = $v; - $this->modifiedColumns[] = AdminLogPeer::ADMIN_FIRSTNAME; - } - - - return $this; - } // setAdminFirstname() - - /** - * Set the value of [admin_lastname] column. - * - * @param string $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setAdminLastname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->admin_lastname !== $v) { - $this->admin_lastname = $v; - $this->modifiedColumns[] = AdminLogPeer::ADMIN_LASTNAME; - } - - - return $this; - } // setAdminLastname() - - /** - * Set the value of [action] column. - * - * @param string $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setAction($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->action !== $v) { - $this->action = $v; - $this->modifiedColumns[] = AdminLogPeer::ACTION; - } - - - return $this; - } // setAction() - - /** - * Set the value of [request] column. - * - * @param string $v new value - * @return AdminLog The current object (for fluent API support) - */ - public function setRequest($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->request !== $v) { - $this->request = $v; - $this->modifiedColumns[] = AdminLogPeer::REQUEST; - } - - - return $this; - } // setRequest() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AdminLog The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AdminLogPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AdminLog The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AdminLogPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->admin_login = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->admin_firstname = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->admin_lastname = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->action = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->request = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = AdminLogPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AdminLog object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AdminLogPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AdminLogQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AdminLogPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AdminLogPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AdminLogPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AdminLogPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AdminLogPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminLogPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AdminLogPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AdminLogPeer::ADMIN_LOGIN)) { - $modifiedColumns[':p' . $index++] = '`admin_login`'; - } - if ($this->isColumnModified(AdminLogPeer::ADMIN_FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`admin_firstname`'; - } - if ($this->isColumnModified(AdminLogPeer::ADMIN_LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`admin_lastname`'; - } - if ($this->isColumnModified(AdminLogPeer::ACTION)) { - $modifiedColumns[':p' . $index++] = '`action`'; - } - if ($this->isColumnModified(AdminLogPeer::REQUEST)) { - $modifiedColumns[':p' . $index++] = '`request`'; - } - if ($this->isColumnModified(AdminLogPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AdminLogPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `admin_log` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`admin_login`': - $stmt->bindValue($identifier, $this->admin_login, PDO::PARAM_STR); - break; - case '`admin_firstname`': - $stmt->bindValue($identifier, $this->admin_firstname, PDO::PARAM_STR); - break; - case '`admin_lastname`': - $stmt->bindValue($identifier, $this->admin_lastname, PDO::PARAM_STR); - break; - case '`action`': - $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); - break; - case '`request`': - $stmt->bindValue($identifier, $this->request, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = AdminLogPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminLogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getAdminLogin(); - break; - case 2: - return $this->getAdminFirstname(); - break; - case 3: - return $this->getAdminLastname(); - break; - case 4: - return $this->getAction(); - break; - case 5: - return $this->getRequest(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) - { - if (isset($alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AdminLog'][$this->getPrimaryKey()] = true; - $keys = AdminLogPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getAdminLogin(), - $keys[2] => $this->getAdminFirstname(), - $keys[3] => $this->getAdminLastname(), - $keys[4] => $this->getAction(), - $keys[5] => $this->getRequest(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AdminLogPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setAdminLogin($value); - break; - case 2: - $this->setAdminFirstname($value); - break; - case 3: - $this->setAdminLastname($value); - break; - case 4: - $this->setAction($value); - break; - case 5: - $this->setRequest($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AdminLogPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setAdminLogin($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAdminFirstname($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAdminLastname($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAction($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setRequest($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AdminLogPeer::DATABASE_NAME); - - if ($this->isColumnModified(AdminLogPeer::ID)) $criteria->add(AdminLogPeer::ID, $this->id); - if ($this->isColumnModified(AdminLogPeer::ADMIN_LOGIN)) $criteria->add(AdminLogPeer::ADMIN_LOGIN, $this->admin_login); - if ($this->isColumnModified(AdminLogPeer::ADMIN_FIRSTNAME)) $criteria->add(AdminLogPeer::ADMIN_FIRSTNAME, $this->admin_firstname); - if ($this->isColumnModified(AdminLogPeer::ADMIN_LASTNAME)) $criteria->add(AdminLogPeer::ADMIN_LASTNAME, $this->admin_lastname); - if ($this->isColumnModified(AdminLogPeer::ACTION)) $criteria->add(AdminLogPeer::ACTION, $this->action); - if ($this->isColumnModified(AdminLogPeer::REQUEST)) $criteria->add(AdminLogPeer::REQUEST, $this->request); - if ($this->isColumnModified(AdminLogPeer::CREATED_AT)) $criteria->add(AdminLogPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AdminLogPeer::UPDATED_AT)) $criteria->add(AdminLogPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AdminLogPeer::DATABASE_NAME); - $criteria->add(AdminLogPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of AdminLog (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setAdminLogin($this->getAdminLogin()); - $copyObj->setAdminFirstname($this->getAdminFirstname()); - $copyObj->setAdminLastname($this->getAdminLastname()); - $copyObj->setAction($this->getAction()); - $copyObj->setRequest($this->getRequest()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return AdminLog Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AdminLogPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AdminLogPeer(); - } - - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->admin_login = null; - $this->admin_firstname = null; - $this->admin_lastname = null; - $this->action = null; - $this->request = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AdminLogPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return AdminLog The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AdminLogPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php b/core/lib/Thelia/Model/om/BaseAdminLogPeer.php deleted file mode 100755 index 3220eda92..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminLogPeer.php +++ /dev/null @@ -1,805 +0,0 @@ - array ('Id', 'AdminLogin', 'AdminFirstname', 'AdminLastname', 'Action', 'Request', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'adminLogin', 'adminFirstname', 'adminLastname', 'action', 'request', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AdminLogPeer::ID, AdminLogPeer::ADMIN_LOGIN, AdminLogPeer::ADMIN_FIRSTNAME, AdminLogPeer::ADMIN_LASTNAME, AdminLogPeer::ACTION, AdminLogPeer::REQUEST, AdminLogPeer::CREATED_AT, AdminLogPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ADMIN_LOGIN', 'ADMIN_FIRSTNAME', 'ADMIN_LASTNAME', 'ACTION', 'REQUEST', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'admin_login', 'admin_firstname', 'admin_lastname', 'action', 'request', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AdminLogPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AdminLogin' => 1, 'AdminFirstname' => 2, 'AdminLastname' => 3, 'Action' => 4, 'Request' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'adminLogin' => 1, 'adminFirstname' => 2, 'adminLastname' => 3, 'action' => 4, 'request' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (AdminLogPeer::ID => 0, AdminLogPeer::ADMIN_LOGIN => 1, AdminLogPeer::ADMIN_FIRSTNAME => 2, AdminLogPeer::ADMIN_LASTNAME => 3, AdminLogPeer::ACTION => 4, AdminLogPeer::REQUEST => 5, AdminLogPeer::CREATED_AT => 6, AdminLogPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ADMIN_LOGIN' => 1, 'ADMIN_FIRSTNAME' => 2, 'ADMIN_LASTNAME' => 3, 'ACTION' => 4, 'REQUEST' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'admin_login' => 1, 'admin_firstname' => 2, 'admin_lastname' => 3, 'action' => 4, 'request' => 5, 'created_at' => 6, 'updated_at' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AdminLogPeer::getFieldNames($toType); - $key = isset(AdminLogPeer::$fieldKeys[$fromType][$name]) ? AdminLogPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminLogPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AdminLogPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AdminLogPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AdminLogPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AdminLogPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AdminLogPeer::ID); - $criteria->addSelectColumn(AdminLogPeer::ADMIN_LOGIN); - $criteria->addSelectColumn(AdminLogPeer::ADMIN_FIRSTNAME); - $criteria->addSelectColumn(AdminLogPeer::ADMIN_LASTNAME); - $criteria->addSelectColumn(AdminLogPeer::ACTION); - $criteria->addSelectColumn(AdminLogPeer::REQUEST); - $criteria->addSelectColumn(AdminLogPeer::CREATED_AT); - $criteria->addSelectColumn(AdminLogPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.admin_login'); - $criteria->addSelectColumn($alias . '.admin_firstname'); - $criteria->addSelectColumn($alias . '.admin_lastname'); - $criteria->addSelectColumn($alias . '.action'); - $criteria->addSelectColumn($alias . '.request'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminLogPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminLogPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AdminLogPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return AdminLog - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AdminLogPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AdminLogPeer::populateObjects(AdminLogPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AdminLogPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AdminLogPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param AdminLog $obj A AdminLog object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AdminLogPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A AdminLog object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof AdminLog) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AdminLog object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AdminLogPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return AdminLog Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AdminLogPeer::$instances[$key])) { - return AdminLogPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AdminLogPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AdminLogPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to admin_log - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AdminLogPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AdminLogPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AdminLogPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AdminLogPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AdminLog object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AdminLogPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AdminLogPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AdminLogPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AdminLogPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AdminLogPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AdminLogPeer::DATABASE_NAME)->getTable(AdminLogPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAdminLogPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAdminLogPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AdminLogTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AdminLogPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AdminLog or Criteria object. - * - * @param mixed $values Criteria or AdminLog object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AdminLog object - } - - if ($criteria->containsKey(AdminLogPeer::ID) && $criteria->keyContainsValue(AdminLogPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminLogPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AdminLogPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a AdminLog or Criteria object. - * - * @param mixed $values Criteria or AdminLog object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AdminLogPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AdminLogPeer::ID); - $value = $criteria->remove(AdminLogPeer::ID); - if ($value) { - $selectCriteria->add(AdminLogPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AdminLogPeer::TABLE_NAME); - } - - } else { // $values is AdminLog object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AdminLogPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the admin_log table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AdminLogPeer::TABLE_NAME, $con, AdminLogPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AdminLogPeer::clearInstancePool(); - AdminLogPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AdminLog or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AdminLog object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AdminLogPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AdminLog) { // it's a model object - // invalidate the cache for this single object - AdminLogPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AdminLogPeer::DATABASE_NAME); - $criteria->add(AdminLogPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AdminLogPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AdminLogPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AdminLogPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AdminLog object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param AdminLog $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AdminLogPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AdminLogPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AdminLogPeer::DATABASE_NAME, AdminLogPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return AdminLog - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AdminLogPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AdminLogPeer::DATABASE_NAME); - $criteria->add(AdminLogPeer::ID, $pk); - - $v = AdminLogPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return AdminLog[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AdminLogPeer::DATABASE_NAME); - $criteria->add(AdminLogPeer::ID, $pks, Criteria::IN); - $objs = AdminLogPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAdminLogPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAdminLogPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php b/core/lib/Thelia/Model/om/BaseAdminLogQuery.php deleted file mode 100755 index 00ff8548f..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminLogQuery.php +++ /dev/null @@ -1,609 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AdminLogPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AdminLogPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AdminLog A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AdminLog A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `admin_login`, `admin_firstname`, `admin_lastname`, `action`, `request`, `created_at`, `updated_at` FROM `admin_log` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AdminLog(); - $obj->hydrate($row); - AdminLogPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AdminLog|AdminLog[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|AdminLog[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AdminLogPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AdminLogPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AdminLogPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AdminLogPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminLogPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the admin_login column - * - * Example usage: - * - * $query->filterByAdminLogin('fooValue'); // WHERE admin_login = 'fooValue' - * $query->filterByAdminLogin('%fooValue%'); // WHERE admin_login LIKE '%fooValue%' - * - * - * @param string $adminLogin The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByAdminLogin($adminLogin = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($adminLogin)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $adminLogin)) { - $adminLogin = str_replace('*', '%', $adminLogin); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminLogPeer::ADMIN_LOGIN, $adminLogin, $comparison); - } - - /** - * Filter the query on the admin_firstname column - * - * Example usage: - * - * $query->filterByAdminFirstname('fooValue'); // WHERE admin_firstname = 'fooValue' - * $query->filterByAdminFirstname('%fooValue%'); // WHERE admin_firstname LIKE '%fooValue%' - * - * - * @param string $adminFirstname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByAdminFirstname($adminFirstname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($adminFirstname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $adminFirstname)) { - $adminFirstname = str_replace('*', '%', $adminFirstname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminLogPeer::ADMIN_FIRSTNAME, $adminFirstname, $comparison); - } - - /** - * Filter the query on the admin_lastname column - * - * Example usage: - * - * $query->filterByAdminLastname('fooValue'); // WHERE admin_lastname = 'fooValue' - * $query->filterByAdminLastname('%fooValue%'); // WHERE admin_lastname LIKE '%fooValue%' - * - * - * @param string $adminLastname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByAdminLastname($adminLastname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($adminLastname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $adminLastname)) { - $adminLastname = str_replace('*', '%', $adminLastname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminLogPeer::ADMIN_LASTNAME, $adminLastname, $comparison); - } - - /** - * Filter the query on the action column - * - * Example usage: - * - * $query->filterByAction('fooValue'); // WHERE action = 'fooValue' - * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%' - * - * - * @param string $action The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByAction($action = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($action)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $action)) { - $action = str_replace('*', '%', $action); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminLogPeer::ACTION, $action, $comparison); - } - - /** - * Filter the query on the request column - * - * Example usage: - * - * $query->filterByRequest('fooValue'); // WHERE request = 'fooValue' - * $query->filterByRequest('%fooValue%'); // WHERE request LIKE '%fooValue%' - * - * - * @param string $request The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByRequest($request = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($request)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $request)) { - $request = str_replace('*', '%', $request); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminLogPeer::REQUEST, $request, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminLogPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminLogPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Exclude object from result - * - * @param AdminLog $adminLog Object to remove from the list of results - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function prune($adminLog = null) - { - if ($adminLog) { - $this->addUsingAlias(AdminLogPeer::ID, $adminLog->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AdminLogPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AdminLogPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AdminLogPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AdminLogPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AdminLogPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AdminLogQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AdminLogPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAdminPeer.php b/core/lib/Thelia/Model/om/BaseAdminPeer.php deleted file mode 100755 index c92832ca6..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminPeer.php +++ /dev/null @@ -1,814 +0,0 @@ - array ('Id', 'Firstname', 'Lastname', 'Login', 'Password', 'Algo', 'Salt', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AdminPeer::ID, AdminPeer::FIRSTNAME, AdminPeer::LASTNAME, AdminPeer::LOGIN, AdminPeer::PASSWORD, AdminPeer::ALGO, AdminPeer::SALT, AdminPeer::CREATED_AT, AdminPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FIRSTNAME', 'LASTNAME', 'LOGIN', 'PASSWORD', 'ALGO', 'SALT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'firstname', 'lastname', 'login', 'password', 'algo', 'salt', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AdminPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Firstname' => 1, 'Lastname' => 2, 'Login' => 3, 'Password' => 4, 'Algo' => 5, 'Salt' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - BasePeer::TYPE_COLNAME => array (AdminPeer::ID => 0, AdminPeer::FIRSTNAME => 1, AdminPeer::LASTNAME => 2, AdminPeer::LOGIN => 3, AdminPeer::PASSWORD => 4, AdminPeer::ALGO => 5, AdminPeer::SALT => 6, AdminPeer::CREATED_AT => 7, AdminPeer::UPDATED_AT => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FIRSTNAME' => 1, 'LASTNAME' => 2, 'LOGIN' => 3, 'PASSWORD' => 4, 'ALGO' => 5, 'SALT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'firstname' => 1, 'lastname' => 2, 'login' => 3, 'password' => 4, 'algo' => 5, 'salt' => 6, 'created_at' => 7, 'updated_at' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AdminPeer::getFieldNames($toType); - $key = isset(AdminPeer::$fieldKeys[$fromType][$name]) ? AdminPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AdminPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AdminPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AdminPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AdminPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AdminPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AdminPeer::ID); - $criteria->addSelectColumn(AdminPeer::FIRSTNAME); - $criteria->addSelectColumn(AdminPeer::LASTNAME); - $criteria->addSelectColumn(AdminPeer::LOGIN); - $criteria->addSelectColumn(AdminPeer::PASSWORD); - $criteria->addSelectColumn(AdminPeer::ALGO); - $criteria->addSelectColumn(AdminPeer::SALT); - $criteria->addSelectColumn(AdminPeer::CREATED_AT); - $criteria->addSelectColumn(AdminPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.firstname'); - $criteria->addSelectColumn($alias . '.lastname'); - $criteria->addSelectColumn($alias . '.login'); - $criteria->addSelectColumn($alias . '.password'); - $criteria->addSelectColumn($alias . '.algo'); - $criteria->addSelectColumn($alias . '.salt'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AdminPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AdminPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AdminPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Admin - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AdminPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AdminPeer::populateObjects(AdminPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AdminPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AdminPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Admin $obj A Admin object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AdminPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Admin object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Admin) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Admin object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AdminPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Admin Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AdminPeer::$instances[$key])) { - return AdminPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AdminPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AdminPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to admin - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AdminGroupPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AdminGroupPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AdminPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AdminPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AdminPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AdminPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Admin object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AdminPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AdminPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AdminPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AdminPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AdminPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AdminPeer::DATABASE_NAME)->getTable(AdminPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAdminPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAdminPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AdminTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AdminPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Admin or Criteria object. - * - * @param mixed $values Criteria or Admin object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Admin object - } - - if ($criteria->containsKey(AdminPeer::ID) && $criteria->keyContainsValue(AdminPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AdminPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Admin or Criteria object. - * - * @param mixed $values Criteria or Admin object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AdminPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AdminPeer::ID); - $value = $criteria->remove(AdminPeer::ID); - if ($value) { - $selectCriteria->add(AdminPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AdminPeer::TABLE_NAME); - } - - } else { // $values is Admin object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AdminPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the admin table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AdminPeer::TABLE_NAME, $con, AdminPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AdminPeer::clearInstancePool(); - AdminPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Admin or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Admin object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AdminPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Admin) { // it's a model object - // invalidate the cache for this single object - AdminPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - $criteria->add(AdminPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AdminPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AdminPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AdminPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Admin object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Admin $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AdminPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AdminPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AdminPeer::DATABASE_NAME, AdminPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Admin - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AdminPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - $criteria->add(AdminPeer::ID, $pk); - - $v = AdminPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Admin[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AdminPeer::DATABASE_NAME); - $criteria->add(AdminPeer::ID, $pks, Criteria::IN); - $objs = AdminPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAdminPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAdminPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAdminQuery.php b/core/lib/Thelia/Model/om/BaseAdminQuery.php deleted file mode 100755 index 9cce7e496..000000000 --- a/core/lib/Thelia/Model/om/BaseAdminQuery.php +++ /dev/null @@ -1,741 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Admin|Admin[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AdminPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AdminPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Admin A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Admin A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `firstname`, `lastname`, `login`, `password`, `algo`, `salt`, `created_at`, `updated_at` FROM `admin` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Admin(); - $obj->hydrate($row); - AdminPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Admin|Admin[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Admin[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AdminPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AdminPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AdminPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AdminPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the firstname column - * - * Example usage: - * - * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue' - * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%' - * - * - * @param string $firstname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByFirstname($firstname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($firstname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $firstname)) { - $firstname = str_replace('*', '%', $firstname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::FIRSTNAME, $firstname, $comparison); - } - - /** - * Filter the query on the lastname column - * - * Example usage: - * - * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue' - * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%' - * - * - * @param string $lastname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByLastname($lastname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lastname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lastname)) { - $lastname = str_replace('*', '%', $lastname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::LASTNAME, $lastname, $comparison); - } - - /** - * Filter the query on the login column - * - * Example usage: - * - * $query->filterByLogin('fooValue'); // WHERE login = 'fooValue' - * $query->filterByLogin('%fooValue%'); // WHERE login LIKE '%fooValue%' - * - * - * @param string $login The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByLogin($login = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($login)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $login)) { - $login = str_replace('*', '%', $login); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::LOGIN, $login, $comparison); - } - - /** - * Filter the query on the password column - * - * Example usage: - * - * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue' - * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%' - * - * - * @param string $password The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByPassword($password = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($password)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $password)) { - $password = str_replace('*', '%', $password); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::PASSWORD, $password, $comparison); - } - - /** - * Filter the query on the algo column - * - * Example usage: - * - * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue' - * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%' - * - * - * @param string $algo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByAlgo($algo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($algo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $algo)) { - $algo = str_replace('*', '%', $algo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::ALGO, $algo, $comparison); - } - - /** - * Filter the query on the salt column - * - * Example usage: - * - * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue' - * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%' - * - * - * @param string $salt The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterBySalt($salt = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($salt)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $salt)) { - $salt = str_replace('*', '%', $salt); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AdminPeer::SALT, $salt, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related AdminGroup object - * - * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAdminGroup($adminGroup, $comparison = null) - { - if ($adminGroup instanceof AdminGroup) { - return $this - ->addUsingAlias(AdminPeer::ID, $adminGroup->getAdminId(), $comparison); - } elseif ($adminGroup instanceof PropelObjectCollection) { - return $this - ->useAdminGroupQuery() - ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AdminGroup relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AdminQuery The current query, for fluid interface - */ - public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AdminGroup'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AdminGroup'); - } - - return $this; - } - - /** - * Use the AdminGroup relation AdminGroup object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query - */ - public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAdminGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); - } - - /** - * Filter the query by a related Group object - * using the admin_group table as cross reference - * - * @param Group $group the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AdminQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = Criteria::EQUAL) - { - return $this - ->useAdminGroupQuery() - ->filterByGroup($group, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Admin $admin Object to remove from the list of results - * - * @return AdminQuery The current query, for fluid interface - */ - public function prune($admin = null) - { - if ($admin) { - $this->addUsingAlias(AdminPeer::ID, $admin->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AdminQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AdminPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AdminQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AdminPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AdminQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AdminPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AdminQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AdminPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AdminQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AdminPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AdminQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AdminPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseArea.php b/core/lib/Thelia/Model/om/BaseArea.php deleted file mode 100755 index d1e06623b..000000000 --- a/core/lib/Thelia/Model/om/BaseArea.php +++ /dev/null @@ -1,1679 +0,0 @@ -id; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get the [unit] column value. - * - * @return double - */ - public function getUnit() - { - return $this->unit; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Area The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AreaPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return Area The current object (for fluent API support) - */ - public function setName($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = AreaPeer::NAME; - } - - - return $this; - } // setName() - - /** - * Set the value of [unit] column. - * - * @param double $v new value - * @return Area The current object (for fluent API support) - */ - public function setUnit($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->unit !== $v) { - $this->unit = $v; - $this->modifiedColumns[] = AreaPeer::UNIT; - } - - - return $this; - } // setUnit() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Area The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AreaPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Area The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AreaPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->unit = ($row[$startcol + 2] !== null) ? (double) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = AreaPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Area object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AreaPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collCountrys = null; - - $this->collDelivzones = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AreaQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AreaPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AreaPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AreaPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AreaPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->countrysScheduledForDeletion !== null) { - if (!$this->countrysScheduledForDeletion->isEmpty()) { - foreach ($this->countrysScheduledForDeletion as $country) { - // need to save related object because we set the relation to null - $country->save($con); - } - $this->countrysScheduledForDeletion = null; - } - } - - if ($this->collCountrys !== null) { - foreach ($this->collCountrys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->delivzonesScheduledForDeletion !== null) { - if (!$this->delivzonesScheduledForDeletion->isEmpty()) { - foreach ($this->delivzonesScheduledForDeletion as $delivzone) { - // need to save related object because we set the relation to null - $delivzone->save($con); - } - $this->delivzonesScheduledForDeletion = null; - } - } - - if ($this->collDelivzones !== null) { - foreach ($this->collDelivzones as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AreaPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AreaPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AreaPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AreaPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`name`'; - } - if ($this->isColumnModified(AreaPeer::UNIT)) { - $modifiedColumns[':p' . $index++] = '`unit`'; - } - if ($this->isColumnModified(AreaPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AreaPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `area` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`name`': - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); - break; - case '`unit`': - $stmt->bindValue($identifier, $this->unit, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = AreaPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCountrys !== null) { - foreach ($this->collCountrys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDelivzones !== null) { - foreach ($this->collDelivzones as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AreaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getName(); - break; - case 2: - return $this->getUnit(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Area'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Area'][$this->getPrimaryKey()] = true; - $keys = AreaPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getName(), - $keys[2] => $this->getUnit(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collCountrys) { - $result['Countrys'] = $this->collCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDelivzones) { - $result['Delivzones'] = $this->collDelivzones->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AreaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setName($value); - break; - case 2: - $this->setUnit($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AreaPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setUnit($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AreaPeer::DATABASE_NAME); - - if ($this->isColumnModified(AreaPeer::ID)) $criteria->add(AreaPeer::ID, $this->id); - if ($this->isColumnModified(AreaPeer::NAME)) $criteria->add(AreaPeer::NAME, $this->name); - if ($this->isColumnModified(AreaPeer::UNIT)) $criteria->add(AreaPeer::UNIT, $this->unit); - if ($this->isColumnModified(AreaPeer::CREATED_AT)) $criteria->add(AreaPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AreaPeer::UPDATED_AT)) $criteria->add(AreaPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AreaPeer::DATABASE_NAME); - $criteria->add(AreaPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Area (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setName($this->getName()); - $copyObj->setUnit($this->getUnit()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getCountrys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCountry($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDelivzones() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDelivzone($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Area Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AreaPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AreaPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Country' == $relationName) { - $this->initCountrys(); - } - if ('Delivzone' == $relationName) { - $this->initDelivzones(); - } - } - - /** - * Clears out the collCountrys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Area The current object (for fluent API support) - * @see addCountrys() - */ - public function clearCountrys() - { - $this->collCountrys = null; // important to set this to null since that means it is uninitialized - $this->collCountrysPartial = null; - - return $this; - } - - /** - * reset is the collCountrys collection loaded partially - * - * @return void - */ - public function resetPartialCountrys($v = true) - { - $this->collCountrysPartial = $v; - } - - /** - * Initializes the collCountrys collection. - * - * By default this just sets the collCountrys collection to an empty array (like clearcollCountrys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCountrys($overrideExisting = true) - { - if (null !== $this->collCountrys && !$overrideExisting) { - return; - } - $this->collCountrys = new PropelObjectCollection(); - $this->collCountrys->setModel('Country'); - } - - /** - * Gets an array of Country objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Area is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Country[] List of Country objects - * @throws PropelException - */ - public function getCountrys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCountrysPartial && !$this->isNew(); - if (null === $this->collCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCountrys) { - // return empty collection - $this->initCountrys(); - } else { - $collCountrys = CountryQuery::create(null, $criteria) - ->filterByArea($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCountrysPartial && count($collCountrys)) { - $this->initCountrys(false); - - foreach($collCountrys as $obj) { - if (false == $this->collCountrys->contains($obj)) { - $this->collCountrys->append($obj); - } - } - - $this->collCountrysPartial = true; - } - - $collCountrys->getInternalIterator()->rewind(); - return $collCountrys; - } - - if($partial && $this->collCountrys) { - foreach($this->collCountrys as $obj) { - if($obj->isNew()) { - $collCountrys[] = $obj; - } - } - } - - $this->collCountrys = $collCountrys; - $this->collCountrysPartial = false; - } - } - - return $this->collCountrys; - } - - /** - * Sets a collection of Country objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $countrys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Area The current object (for fluent API support) - */ - public function setCountrys(PropelCollection $countrys, PropelPDO $con = null) - { - $countrysToDelete = $this->getCountrys(new Criteria(), $con)->diff($countrys); - - $this->countrysScheduledForDeletion = unserialize(serialize($countrysToDelete)); - - foreach ($countrysToDelete as $countryRemoved) { - $countryRemoved->setArea(null); - } - - $this->collCountrys = null; - foreach ($countrys as $country) { - $this->addCountry($country); - } - - $this->collCountrys = $countrys; - $this->collCountrysPartial = false; - - return $this; - } - - /** - * Returns the number of related Country objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Country objects. - * @throws PropelException - */ - public function countCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCountrysPartial && !$this->isNew(); - if (null === $this->collCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCountrys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCountrys()); - } - $query = CountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByArea($this) - ->count($con); - } - - return count($this->collCountrys); - } - - /** - * Method called to associate a Country object to this object - * through the Country foreign key attribute. - * - * @param Country $l Country - * @return Area The current object (for fluent API support) - */ - public function addCountry(Country $l) - { - if ($this->collCountrys === null) { - $this->initCountrys(); - $this->collCountrysPartial = true; - } - if (!in_array($l, $this->collCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCountry($l); - } - - return $this; - } - - /** - * @param Country $country The country object to add. - */ - protected function doAddCountry($country) - { - $this->collCountrys[]= $country; - $country->setArea($this); - } - - /** - * @param Country $country The country object to remove. - * @return Area The current object (for fluent API support) - */ - public function removeCountry($country) - { - if ($this->getCountrys()->contains($country)) { - $this->collCountrys->remove($this->collCountrys->search($country)); - if (null === $this->countrysScheduledForDeletion) { - $this->countrysScheduledForDeletion = clone $this->collCountrys; - $this->countrysScheduledForDeletion->clear(); - } - $this->countrysScheduledForDeletion[]= $country; - $country->setArea(null); - } - - return $this; - } - - /** - * Clears out the collDelivzones collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Area The current object (for fluent API support) - * @see addDelivzones() - */ - public function clearDelivzones() - { - $this->collDelivzones = null; // important to set this to null since that means it is uninitialized - $this->collDelivzonesPartial = null; - - return $this; - } - - /** - * reset is the collDelivzones collection loaded partially - * - * @return void - */ - public function resetPartialDelivzones($v = true) - { - $this->collDelivzonesPartial = $v; - } - - /** - * Initializes the collDelivzones collection. - * - * By default this just sets the collDelivzones collection to an empty array (like clearcollDelivzones()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDelivzones($overrideExisting = true) - { - if (null !== $this->collDelivzones && !$overrideExisting) { - return; - } - $this->collDelivzones = new PropelObjectCollection(); - $this->collDelivzones->setModel('Delivzone'); - } - - /** - * Gets an array of Delivzone objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Area is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Delivzone[] List of Delivzone objects - * @throws PropelException - */ - public function getDelivzones($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { - // return empty collection - $this->initDelivzones(); - } else { - $collDelivzones = DelivzoneQuery::create(null, $criteria) - ->filterByArea($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDelivzonesPartial && count($collDelivzones)) { - $this->initDelivzones(false); - - foreach($collDelivzones as $obj) { - if (false == $this->collDelivzones->contains($obj)) { - $this->collDelivzones->append($obj); - } - } - - $this->collDelivzonesPartial = true; - } - - $collDelivzones->getInternalIterator()->rewind(); - return $collDelivzones; - } - - if($partial && $this->collDelivzones) { - foreach($this->collDelivzones as $obj) { - if($obj->isNew()) { - $collDelivzones[] = $obj; - } - } - } - - $this->collDelivzones = $collDelivzones; - $this->collDelivzonesPartial = false; - } - } - - return $this->collDelivzones; - } - - /** - * Sets a collection of Delivzone objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $delivzones A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Area The current object (for fluent API support) - */ - public function setDelivzones(PropelCollection $delivzones, PropelPDO $con = null) - { - $delivzonesToDelete = $this->getDelivzones(new Criteria(), $con)->diff($delivzones); - - $this->delivzonesScheduledForDeletion = unserialize(serialize($delivzonesToDelete)); - - foreach ($delivzonesToDelete as $delivzoneRemoved) { - $delivzoneRemoved->setArea(null); - } - - $this->collDelivzones = null; - foreach ($delivzones as $delivzone) { - $this->addDelivzone($delivzone); - } - - $this->collDelivzones = $delivzones; - $this->collDelivzonesPartial = false; - - return $this; - } - - /** - * Returns the number of related Delivzone objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Delivzone objects. - * @throws PropelException - */ - public function countDelivzones(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDelivzonesPartial && !$this->isNew(); - if (null === $this->collDelivzones || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDelivzones) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDelivzones()); - } - $query = DelivzoneQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByArea($this) - ->count($con); - } - - return count($this->collDelivzones); - } - - /** - * Method called to associate a Delivzone object to this object - * through the Delivzone foreign key attribute. - * - * @param Delivzone $l Delivzone - * @return Area The current object (for fluent API support) - */ - public function addDelivzone(Delivzone $l) - { - if ($this->collDelivzones === null) { - $this->initDelivzones(); - $this->collDelivzonesPartial = true; - } - if (!in_array($l, $this->collDelivzones->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDelivzone($l); - } - - return $this; - } - - /** - * @param Delivzone $delivzone The delivzone object to add. - */ - protected function doAddDelivzone($delivzone) - { - $this->collDelivzones[]= $delivzone; - $delivzone->setArea($this); - } - - /** - * @param Delivzone $delivzone The delivzone object to remove. - * @return Area The current object (for fluent API support) - */ - public function removeDelivzone($delivzone) - { - if ($this->getDelivzones()->contains($delivzone)) { - $this->collDelivzones->remove($this->collDelivzones->search($delivzone)); - if (null === $this->delivzonesScheduledForDeletion) { - $this->delivzonesScheduledForDeletion = clone $this->collDelivzones; - $this->delivzonesScheduledForDeletion->clear(); - } - $this->delivzonesScheduledForDeletion[]= $delivzone; - $delivzone->setArea(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->unit = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collCountrys) { - foreach ($this->collCountrys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDelivzones) { - foreach ($this->collDelivzones as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collCountrys instanceof PropelCollection) { - $this->collCountrys->clearIterator(); - } - $this->collCountrys = null; - if ($this->collDelivzones instanceof PropelCollection) { - $this->collDelivzones->clearIterator(); - } - $this->collDelivzones = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AreaPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Area The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AreaPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAreaPeer.php b/core/lib/Thelia/Model/om/BaseAreaPeer.php deleted file mode 100755 index b543e5ac7..000000000 --- a/core/lib/Thelia/Model/om/BaseAreaPeer.php +++ /dev/null @@ -1,798 +0,0 @@ - array ('Id', 'Name', 'Unit', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'unit', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AreaPeer::ID, AreaPeer::NAME, AreaPeer::UNIT, AreaPeer::CREATED_AT, AreaPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'UNIT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'unit', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AreaPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Unit' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'unit' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (AreaPeer::ID => 0, AreaPeer::NAME => 1, AreaPeer::UNIT => 2, AreaPeer::CREATED_AT => 3, AreaPeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'UNIT' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'unit' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AreaPeer::getFieldNames($toType); - $key = isset(AreaPeer::$fieldKeys[$fromType][$name]) ? AreaPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AreaPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AreaPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AreaPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AreaPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AreaPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AreaPeer::ID); - $criteria->addSelectColumn(AreaPeer::NAME); - $criteria->addSelectColumn(AreaPeer::UNIT); - $criteria->addSelectColumn(AreaPeer::CREATED_AT); - $criteria->addSelectColumn(AreaPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.name'); - $criteria->addSelectColumn($alias . '.unit'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AreaPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AreaPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AreaPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Area - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AreaPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AreaPeer::populateObjects(AreaPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AreaPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AreaPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Area $obj A Area object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AreaPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Area object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Area) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Area object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AreaPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Area Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AreaPeer::$instances[$key])) { - return AreaPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AreaPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AreaPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to area - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CountryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CountryPeer::clearInstancePool(); - // Invalidate objects in DelivzonePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DelivzonePeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AreaPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AreaPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AreaPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AreaPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Area object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AreaPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AreaPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AreaPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AreaPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AreaPeer::DATABASE_NAME)->getTable(AreaPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAreaPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAreaPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AreaTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AreaPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Area or Criteria object. - * - * @param mixed $values Criteria or Area object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Area object - } - - if ($criteria->containsKey(AreaPeer::ID) && $criteria->keyContainsValue(AreaPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AreaPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AreaPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Area or Criteria object. - * - * @param mixed $values Criteria or Area object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AreaPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AreaPeer::ID); - $value = $criteria->remove(AreaPeer::ID); - if ($value) { - $selectCriteria->add(AreaPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AreaPeer::TABLE_NAME); - } - - } else { // $values is Area object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AreaPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the area table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AreaPeer::TABLE_NAME, $con, AreaPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AreaPeer::clearInstancePool(); - AreaPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Area or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Area object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AreaPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Area) { // it's a model object - // invalidate the cache for this single object - AreaPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AreaPeer::DATABASE_NAME); - $criteria->add(AreaPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AreaPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AreaPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AreaPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Area object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Area $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AreaPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AreaPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AreaPeer::DATABASE_NAME, AreaPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Area - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AreaPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AreaPeer::DATABASE_NAME); - $criteria->add(AreaPeer::ID, $pk); - - $v = AreaPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Area[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AreaPeer::DATABASE_NAME); - $criteria->add(AreaPeer::ID, $pks, Criteria::IN); - $objs = AreaPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAreaPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAreaPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAreaQuery.php b/core/lib/Thelia/Model/om/BaseAreaQuery.php deleted file mode 100755 index 3feaaca2f..000000000 --- a/core/lib/Thelia/Model/om/BaseAreaQuery.php +++ /dev/null @@ -1,683 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Area|Area[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AreaPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AreaPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Area A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Area A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `name`, `unit`, `created_at`, `updated_at` FROM `area` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Area(); - $obj->hydrate($row); - AreaPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Area|Area[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Area[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AreaPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AreaPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AreaPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AreaPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AreaPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the name column - * - * Example usage: - * - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' - * - * - * @param string $name The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByName($name = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($name)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $name)) { - $name = str_replace('*', '%', $name); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AreaPeer::NAME, $name, $comparison); - } - - /** - * Filter the query on the unit column - * - * Example usage: - * - * $query->filterByUnit(1234); // WHERE unit = 1234 - * $query->filterByUnit(array(12, 34)); // WHERE unit IN (12, 34) - * $query->filterByUnit(array('min' => 12)); // WHERE unit >= 12 - * $query->filterByUnit(array('max' => 12)); // WHERE unit <= 12 - * - * - * @param mixed $unit The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByUnit($unit = null, $comparison = null) - { - if (is_array($unit)) { - $useMinMax = false; - if (isset($unit['min'])) { - $this->addUsingAlias(AreaPeer::UNIT, $unit['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($unit['max'])) { - $this->addUsingAlias(AreaPeer::UNIT, $unit['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AreaPeer::UNIT, $unit, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AreaPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AreaPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Country object - * - * @param Country|PropelObjectCollection $country the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCountry($country, $comparison = null) - { - if ($country instanceof Country) { - return $this - ->addUsingAlias(AreaPeer::ID, $country->getAreaId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { - return $this - ->useCountryQuery() - ->filterByPrimaryKeys($country->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Country relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AreaQuery The current query, for fluid interface - */ - public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Country'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Country'); - } - - return $this; - } - - /** - * Use the Country relation Country object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query - */ - public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery'); - } - - /** - * Filter the query by a related Delivzone object - * - * @param Delivzone|PropelObjectCollection $delivzone the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AreaQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDelivzone($delivzone, $comparison = null) - { - if ($delivzone instanceof Delivzone) { - return $this - ->addUsingAlias(AreaPeer::ID, $delivzone->getAreaId(), $comparison); - } elseif ($delivzone instanceof PropelObjectCollection) { - return $this - ->useDelivzoneQuery() - ->filterByPrimaryKeys($delivzone->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDelivzone() only accepts arguments of type Delivzone or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Delivzone relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AreaQuery The current query, for fluid interface - */ - public function joinDelivzone($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Delivzone'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Delivzone'); - } - - return $this; - } - - /** - * Use the Delivzone relation Delivzone object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DelivzoneQuery A secondary query class using the current class as primary query - */ - public function useDelivzoneQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDelivzone($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Delivzone', '\Thelia\Model\DelivzoneQuery'); - } - - /** - * Exclude object from result - * - * @param Area $area Object to remove from the list of results - * - * @return AreaQuery The current query, for fluid interface - */ - public function prune($area = null) - { - if ($area) { - $this->addUsingAlias(AreaPeer::ID, $area->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AreaQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AreaPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AreaQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AreaPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AreaQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AreaPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AreaQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AreaPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AreaQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AreaPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AreaQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AreaPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAttribute.php b/core/lib/Thelia/Model/om/BaseAttribute.php deleted file mode 100755 index 9deb6fe5e..000000000 --- a/core/lib/Thelia/Model/om/BaseAttribute.php +++ /dev/null @@ -1,2700 +0,0 @@ -id; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Attribute The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Attribute The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = AttributePeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Attribute The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AttributePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Attribute The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AttributePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->position = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = AttributePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Attribute object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AttributePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAttributeAvs = null; - - $this->collAttributeCombinations = null; - - $this->collAttributeCategorys = null; - - $this->collAttributeI18ns = null; - - $this->collCategorys = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AttributePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AttributePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AttributePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->categorysScheduledForDeletion = null; - } - - foreach ($this->getCategorys() as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } - - if ($this->attributeAvsScheduledForDeletion !== null) { - if (!$this->attributeAvsScheduledForDeletion->isEmpty()) { - AttributeAvQuery::create() - ->filterByPrimaryKeys($this->attributeAvsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeAvsScheduledForDeletion = null; - } - } - - if ($this->collAttributeAvs !== null) { - foreach ($this->collAttributeAvs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeCombinationsScheduledForDeletion !== null) { - if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() - ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCombinationsScheduledForDeletion = null; - } - } - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeCategorysScheduledForDeletion !== null) { - if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeI18nsScheduledForDeletion !== null) { - if (!$this->attributeI18nsScheduledForDeletion->isEmpty()) { - AttributeI18nQuery::create() - ->filterByPrimaryKeys($this->attributeI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeI18nsScheduledForDeletion = null; - } - } - - if ($this->collAttributeI18ns !== null) { - foreach ($this->collAttributeI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AttributePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(AttributePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AttributePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = AttributePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAttributeAvs !== null) { - foreach ($this->collAttributeAvs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAttributeI18ns !== null) { - foreach ($this->collAttributeI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getPosition(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Attribute'][$this->getPrimaryKey()] = true; - $keys = AttributePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getPosition(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collAttributeAvs) { - $result['AttributeAvs'] = $this->collAttributeAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeCombinations) { - $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeCategorys) { - $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeI18ns) { - $result['AttributeI18ns'] = $this->collAttributeI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setPosition($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AttributePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributePeer::ID)) $criteria->add(AttributePeer::ID, $this->id); - if ($this->isColumnModified(AttributePeer::POSITION)) $criteria->add(AttributePeer::POSITION, $this->position); - if ($this->isColumnModified(AttributePeer::CREATED_AT)) $criteria->add(AttributePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributePeer::UPDATED_AT)) $criteria->add(AttributePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - $criteria->add(AttributePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Attribute (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAttributeAvs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeAv($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeCombinations() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCombination($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Attribute Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AttributePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AttributeAv' == $relationName) { - $this->initAttributeAvs(); - } - if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); - } - if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); - } - if ('AttributeI18n' == $relationName) { - $this->initAttributeI18ns(); - } - } - - /** - * Clears out the collAttributeAvs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Attribute The current object (for fluent API support) - * @see addAttributeAvs() - */ - public function clearAttributeAvs() - { - $this->collAttributeAvs = null; // important to set this to null since that means it is uninitialized - $this->collAttributeAvsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeAvs collection loaded partially - * - * @return void - */ - public function resetPartialAttributeAvs($v = true) - { - $this->collAttributeAvsPartial = $v; - } - - /** - * Initializes the collAttributeAvs collection. - * - * By default this just sets the collAttributeAvs collection to an empty array (like clearcollAttributeAvs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeAvs($overrideExisting = true) - { - if (null !== $this->collAttributeAvs && !$overrideExisting) { - return; - } - $this->collAttributeAvs = new PropelObjectCollection(); - $this->collAttributeAvs->setModel('AttributeAv'); - } - - /** - * Gets an array of AttributeAv objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeAv[] List of AttributeAv objects - * @throws PropelException - */ - public function getAttributeAvs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeAvsPartial && !$this->isNew(); - if (null === $this->collAttributeAvs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeAvs) { - // return empty collection - $this->initAttributeAvs(); - } else { - $collAttributeAvs = AttributeAvQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeAvsPartial && count($collAttributeAvs)) { - $this->initAttributeAvs(false); - - foreach($collAttributeAvs as $obj) { - if (false == $this->collAttributeAvs->contains($obj)) { - $this->collAttributeAvs->append($obj); - } - } - - $this->collAttributeAvsPartial = true; - } - - $collAttributeAvs->getInternalIterator()->rewind(); - return $collAttributeAvs; - } - - if($partial && $this->collAttributeAvs) { - foreach($this->collAttributeAvs as $obj) { - if($obj->isNew()) { - $collAttributeAvs[] = $obj; - } - } - } - - $this->collAttributeAvs = $collAttributeAvs; - $this->collAttributeAvsPartial = false; - } - } - - return $this->collAttributeAvs; - } - - /** - * Sets a collection of AttributeAv objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeAvs A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Attribute The current object (for fluent API support) - */ - public function setAttributeAvs(PropelCollection $attributeAvs, PropelPDO $con = null) - { - $attributeAvsToDelete = $this->getAttributeAvs(new Criteria(), $con)->diff($attributeAvs); - - $this->attributeAvsScheduledForDeletion = unserialize(serialize($attributeAvsToDelete)); - - foreach ($attributeAvsToDelete as $attributeAvRemoved) { - $attributeAvRemoved->setAttribute(null); - } - - $this->collAttributeAvs = null; - foreach ($attributeAvs as $attributeAv) { - $this->addAttributeAv($attributeAv); - } - - $this->collAttributeAvs = $attributeAvs; - $this->collAttributeAvsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeAv objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeAv objects. - * @throws PropelException - */ - public function countAttributeAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeAvsPartial && !$this->isNew(); - if (null === $this->collAttributeAvs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeAvs) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeAvs()); - } - $query = AttributeAvQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); - } - - return count($this->collAttributeAvs); - } - - /** - * Method called to associate a AttributeAv object to this object - * through the AttributeAv foreign key attribute. - * - * @param AttributeAv $l AttributeAv - * @return Attribute The current object (for fluent API support) - */ - public function addAttributeAv(AttributeAv $l) - { - if ($this->collAttributeAvs === null) { - $this->initAttributeAvs(); - $this->collAttributeAvsPartial = true; - } - if (!in_array($l, $this->collAttributeAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeAv($l); - } - - return $this; - } - - /** - * @param AttributeAv $attributeAv The attributeAv object to add. - */ - protected function doAddAttributeAv($attributeAv) - { - $this->collAttributeAvs[]= $attributeAv; - $attributeAv->setAttribute($this); - } - - /** - * @param AttributeAv $attributeAv The attributeAv object to remove. - * @return Attribute The current object (for fluent API support) - */ - public function removeAttributeAv($attributeAv) - { - if ($this->getAttributeAvs()->contains($attributeAv)) { - $this->collAttributeAvs->remove($this->collAttributeAvs->search($attributeAv)); - if (null === $this->attributeAvsScheduledForDeletion) { - $this->attributeAvsScheduledForDeletion = clone $this->collAttributeAvs; - $this->attributeAvsScheduledForDeletion->clear(); - } - $this->attributeAvsScheduledForDeletion[]= clone $attributeAv; - $attributeAv->setAttribute(null); - } - - return $this; - } - - /** - * Clears out the collAttributeCombinations collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Attribute The current object (for fluent API support) - * @see addAttributeCombinations() - */ - public function clearAttributeCombinations() - { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCombinations($v = true) - { - $this->collAttributeCombinationsPartial = $v; - } - - /** - * Initializes the collAttributeCombinations collection. - * - * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCombinations($overrideExisting = true) - { - if (null !== $this->collAttributeCombinations && !$overrideExisting) { - return; - } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); - } - - /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - * @throws PropelException - */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - // return empty collection - $this->initAttributeCombinations(); - } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); - - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); - } - } - - $this->collAttributeCombinationsPartial = true; - } - - $collAttributeCombinations->getInternalIterator()->rewind(); - return $collAttributeCombinations; - } - - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { - $collAttributeCombinations[] = $obj; - } - } - } - - $this->collAttributeCombinations = $collAttributeCombinations; - $this->collAttributeCombinationsPartial = false; - } - } - - return $this->collAttributeCombinations; - } - - /** - * Sets a collection of AttributeCombination objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCombinations A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Attribute The current object (for fluent API support) - */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) - { - $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); - - foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { - $attributeCombinationRemoved->setAttribute(null); - } - - $this->collAttributeCombinations = null; - foreach ($attributeCombinations as $attributeCombination) { - $this->addAttributeCombination($attributeCombination); - } - - $this->collAttributeCombinations = $attributeCombinations; - $this->collAttributeCombinationsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCombination objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCombination objects. - * @throws PropelException - */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); - } - - return count($this->collAttributeCombinations); - } - - /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. - * - * @param AttributeCombination $l AttributeCombination - * @return Attribute The current object (for fluent API support) - */ - public function addAttributeCombination(AttributeCombination $l) - { - if ($this->collAttributeCombinations === null) { - $this->initAttributeCombinations(); - $this->collAttributeCombinationsPartial = true; - } - if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCombination($l); - } - - return $this; - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. - */ - protected function doAddAttributeCombination($attributeCombination) - { - $this->collAttributeCombinations[]= $attributeCombination; - $attributeCombination->setAttribute($this); - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return Attribute The current object (for fluent API support) - */ - public function removeAttributeCombination($attributeCombination) - { - if ($this->getAttributeCombinations()->contains($attributeCombination)) { - $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination)); - if (null === $this->attributeCombinationsScheduledForDeletion) { - $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; - $this->attributeCombinationsScheduledForDeletion->clear(); - } - $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; - $attributeCombination->setAttribute(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Attribute is new, it will return - * an empty collection; or if this Attribute has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Attribute. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('AttributeAv', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Attribute is new, it will return - * an empty collection; or if this Attribute has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Attribute. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - /** - * Clears out the collAttributeCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Attribute The current object (for fluent API support) - * @see addAttributeCategorys() - */ - public function clearAttributeCategorys() - { - $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCategorysPartial = null; - - return $this; - } - - /** - * reset is the collAttributeCategorys collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCategorys($v = true) - { - $this->collAttributeCategorysPartial = $v; - } - - /** - * Initializes the collAttributeCategorys collection. - * - * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCategorys($overrideExisting = true) - { - if (null !== $this->collAttributeCategorys && !$overrideExisting) { - return; - } - $this->collAttributeCategorys = new PropelObjectCollection(); - $this->collAttributeCategorys->setModel('AttributeCategory'); - } - - /** - * Gets an array of AttributeCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - * @throws PropelException - */ - public function getAttributeCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { - // return empty collection - $this->initAttributeCategorys(); - } else { - $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { - $this->initAttributeCategorys(false); - - foreach($collAttributeCategorys as $obj) { - if (false == $this->collAttributeCategorys->contains($obj)) { - $this->collAttributeCategorys->append($obj); - } - } - - $this->collAttributeCategorysPartial = true; - } - - $collAttributeCategorys->getInternalIterator()->rewind(); - return $collAttributeCategorys; - } - - if($partial && $this->collAttributeCategorys) { - foreach($this->collAttributeCategorys as $obj) { - if($obj->isNew()) { - $collAttributeCategorys[] = $obj; - } - } - } - - $this->collAttributeCategorys = $collAttributeCategorys; - $this->collAttributeCategorysPartial = false; - } - } - - return $this->collAttributeCategorys; - } - - /** - * Sets a collection of AttributeCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Attribute The current object (for fluent API support) - */ - public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) - { - $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - - $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); - - foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { - $attributeCategoryRemoved->setAttribute(null); - } - - $this->collAttributeCategorys = null; - foreach ($attributeCategorys as $attributeCategory) { - $this->addAttributeCategory($attributeCategory); - } - - $this->collAttributeCategorys = $attributeCategorys; - $this->collAttributeCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCategory objects. - * @throws PropelException - */ - public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); - } - $query = AttributeCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); - } - - return count($this->collAttributeCategorys); - } - - /** - * Method called to associate a AttributeCategory object to this object - * through the AttributeCategory foreign key attribute. - * - * @param AttributeCategory $l AttributeCategory - * @return Attribute The current object (for fluent API support) - */ - public function addAttributeCategory(AttributeCategory $l) - { - if ($this->collAttributeCategorys === null) { - $this->initAttributeCategorys(); - $this->collAttributeCategorysPartial = true; - } - if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCategory($l); - } - - return $this; - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. - */ - protected function doAddAttributeCategory($attributeCategory) - { - $this->collAttributeCategorys[]= $attributeCategory; - $attributeCategory->setAttribute($this); - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - * @return Attribute The current object (for fluent API support) - */ - public function removeAttributeCategory($attributeCategory) - { - if ($this->getAttributeCategorys()->contains($attributeCategory)) { - $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory)); - if (null === $this->attributeCategorysScheduledForDeletion) { - $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; - $this->attributeCategorysScheduledForDeletion->clear(); - } - $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; - $attributeCategory->setAttribute(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Attribute is new, it will return - * an empty collection; or if this Attribute has previously - * been saved, it will retrieve related AttributeCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Attribute. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - */ - public function getAttributeCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getAttributeCategorys($query, $con); - } - - /** - * Clears out the collAttributeI18ns 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 Attribute The current object (for fluent API support) - * @see addAttributeI18ns() - */ - public function clearAttributeI18ns() - { - $this->collAttributeI18ns = null; // important to set this to null since that means it is uninitialized - $this->collAttributeI18nsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeI18ns collection loaded partially - * - * @return void - */ - public function resetPartialAttributeI18ns($v = true) - { - $this->collAttributeI18nsPartial = $v; - } - - /** - * Initializes the collAttributeI18ns collection. - * - * By default this just sets the collAttributeI18ns collection to an empty array (like clearcollAttributeI18ns()); - * 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 initAttributeI18ns($overrideExisting = true) - { - if (null !== $this->collAttributeI18ns && !$overrideExisting) { - return; - } - $this->collAttributeI18ns = new PropelObjectCollection(); - $this->collAttributeI18ns->setModel('AttributeI18n'); - } - - /** - * Gets an array of AttributeI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeI18n[] List of AttributeI18n objects - * @throws PropelException - */ - public function getAttributeI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeI18nsPartial && !$this->isNew(); - if (null === $this->collAttributeI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeI18ns) { - // return empty collection - $this->initAttributeI18ns(); - } else { - $collAttributeI18ns = AttributeI18nQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeI18nsPartial && count($collAttributeI18ns)) { - $this->initAttributeI18ns(false); - - foreach($collAttributeI18ns as $obj) { - if (false == $this->collAttributeI18ns->contains($obj)) { - $this->collAttributeI18ns->append($obj); - } - } - - $this->collAttributeI18nsPartial = true; - } - - $collAttributeI18ns->getInternalIterator()->rewind(); - return $collAttributeI18ns; - } - - if($partial && $this->collAttributeI18ns) { - foreach($this->collAttributeI18ns as $obj) { - if($obj->isNew()) { - $collAttributeI18ns[] = $obj; - } - } - } - - $this->collAttributeI18ns = $collAttributeI18ns; - $this->collAttributeI18nsPartial = false; - } - } - - return $this->collAttributeI18ns; - } - - /** - * Sets a collection of AttributeI18n 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 $attributeI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Attribute The current object (for fluent API support) - */ - public function setAttributeI18ns(PropelCollection $attributeI18ns, PropelPDO $con = null) - { - $attributeI18nsToDelete = $this->getAttributeI18ns(new Criteria(), $con)->diff($attributeI18ns); - - $this->attributeI18nsScheduledForDeletion = unserialize(serialize($attributeI18nsToDelete)); - - foreach ($attributeI18nsToDelete as $attributeI18nRemoved) { - $attributeI18nRemoved->setAttribute(null); - } - - $this->collAttributeI18ns = null; - foreach ($attributeI18ns as $attributeI18n) { - $this->addAttributeI18n($attributeI18n); - } - - $this->collAttributeI18ns = $attributeI18ns; - $this->collAttributeI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeI18n objects. - * @throws PropelException - */ - public function countAttributeI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeI18nsPartial && !$this->isNew(); - if (null === $this->collAttributeI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeI18ns()); - } - $query = AttributeI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); - } - - return count($this->collAttributeI18ns); - } - - /** - * Method called to associate a AttributeI18n object to this object - * through the AttributeI18n foreign key attribute. - * - * @param AttributeI18n $l AttributeI18n - * @return Attribute The current object (for fluent API support) - */ - public function addAttributeI18n(AttributeI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collAttributeI18ns === null) { - $this->initAttributeI18ns(); - $this->collAttributeI18nsPartial = true; - } - if (!in_array($l, $this->collAttributeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeI18n($l); - } - - return $this; - } - - /** - * @param AttributeI18n $attributeI18n The attributeI18n object to add. - */ - protected function doAddAttributeI18n($attributeI18n) - { - $this->collAttributeI18ns[]= $attributeI18n; - $attributeI18n->setAttribute($this); - } - - /** - * @param AttributeI18n $attributeI18n The attributeI18n object to remove. - * @return Attribute The current object (for fluent API support) - */ - public function removeAttributeI18n($attributeI18n) - { - if ($this->getAttributeI18ns()->contains($attributeI18n)) { - $this->collAttributeI18ns->remove($this->collAttributeI18ns->search($attributeI18n)); - if (null === $this->attributeI18nsScheduledForDeletion) { - $this->attributeI18nsScheduledForDeletion = clone $this->collAttributeI18ns; - $this->attributeI18nsScheduledForDeletion->clear(); - } - $this->attributeI18nsScheduledForDeletion[]= clone $attributeI18n; - $attributeI18n->setAttribute(null); - } - - return $this; - } - - /** - * Clears out the collCategorys 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 Attribute The current object (for fluent API support) - * @see addCategorys() - */ - public function clearCategorys() - { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; - } - - /** - * Initializes the collCategorys collection. - * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); - * 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. - * - * @return void - */ - public function initCategorys() - { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); - } - - /** - * Gets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Attribute is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Category[] List of Category objects - */ - public function getCategorys($criteria = null, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - // return empty collection - $this->initCategorys(); - } else { - $collCategorys = CategoryQuery::create(null, $criteria) - ->filterByAttribute($this) - ->find($con); - if (null !== $criteria) { - return $collCategorys; - } - $this->collCategorys = $collCategorys; - } - } - - return $this->collCategorys; - } - - /** - * Sets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * 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 $categorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Attribute The current object (for fluent API support) - */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) - { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); - - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); - - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { - $this->doAddCategory($category); - } - } - - $this->collCategorys = $categorys; - - return $this; - } - - /** - * Gets the number of Category objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Category objects - */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - return 0; - } else { - $query = CategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttribute($this) - ->count($con); - } - } else { - return count($this->collCategorys); - } - } - - /** - * Associate a Category object to this object - * through the attribute_category cross reference table. - * - * @param Category $category The AttributeCategory object to relate - * @return Attribute The current object (for fluent API support) - */ - public function addCategory(Category $category) - { - if ($this->collCategorys === null) { - $this->initCategorys(); - } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - - $this->collCategorys[]= $category; - } - - return $this; - } - - /** - * @param Category $category The category object to add. - */ - protected function doAddCategory($category) - { - $attributeCategory = new AttributeCategory(); - $attributeCategory->setCategory($category); - $this->addAttributeCategory($attributeCategory); - } - - /** - * Remove a Category object to this object - * through the attribute_category cross reference table. - * - * @param Category $category The AttributeCategory object to relate - * @return Attribute The current object (for fluent API support) - */ - public function removeCategory(Category $category) - { - if ($this->getCategorys()->contains($category)) { - $this->collCategorys->remove($this->collCategorys->search($category)); - if (null === $this->categorysScheduledForDeletion) { - $this->categorysScheduledForDeletion = clone $this->collCategorys; - $this->categorysScheduledForDeletion->clear(); - } - $this->categorysScheduledForDeletion[]= $category; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAttributeAvs) { - foreach ($this->collAttributeAvs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeCombinations) { - foreach ($this->collAttributeCombinations as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeI18ns) { - foreach ($this->collAttributeI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collAttributeAvs instanceof PropelCollection) { - $this->collAttributeAvs->clearIterator(); - } - $this->collAttributeAvs = null; - if ($this->collAttributeCombinations instanceof PropelCollection) { - $this->collAttributeCombinations->clearIterator(); - } - $this->collAttributeCombinations = null; - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); - } - $this->collAttributeCategorys = null; - if ($this->collAttributeI18ns instanceof PropelCollection) { - $this->collAttributeI18ns->clearIterator(); - } - $this->collAttributeI18ns = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); - } - $this->collCategorys = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Attribute The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AttributePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Attribute The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return AttributeI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collAttributeI18ns) { - foreach ($this->collAttributeI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new AttributeI18n(); - $translation->setLocale($locale); - } else { - $translation = AttributeI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addAttributeI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Attribute The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - AttributeI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collAttributeI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collAttributeI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return AttributeI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeAv.php b/core/lib/Thelia/Model/om/BaseAttributeAv.php deleted file mode 100755 index c6a4301a0..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAv.php +++ /dev/null @@ -1,2042 +0,0 @@ -id; - } - - /** - * Get the [attribute_id] column value. - * - * @return int - */ - public function getAttributeId() - { - return $this->attribute_id; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AttributeAv The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributeAvPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [attribute_id] column. - * - * @param int $v new value - * @return AttributeAv The current object (for fluent API support) - */ - public function setAttributeId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->attribute_id !== $v) { - $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeAvPeer::ATTRIBUTE_ID; - } - - if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { - $this->aAttribute = null; - } - - - return $this; - } // setAttributeId() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return AttributeAv The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = AttributeAvPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeAv The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AttributeAvPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeAv The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AttributeAvPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->attribute_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = AttributeAvPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AttributeAv object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { - $this->aAttribute = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AttributeAvPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aAttribute = null; - $this->collAttributeCombinations = null; - - $this->collAttributeAvI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeAvQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AttributeAvPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AttributeAvPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { - $affectedRows += $this->aAttribute->save($con); - } - $this->setAttribute($this->aAttribute); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->attributeCombinationsScheduledForDeletion !== null) { - if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() - ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCombinationsScheduledForDeletion = null; - } - } - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeAvI18nsScheduledForDeletion !== null) { - if (!$this->attributeAvI18nsScheduledForDeletion->isEmpty()) { - AttributeAvI18nQuery::create() - ->filterByPrimaryKeys($this->attributeAvI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeAvI18nsScheduledForDeletion = null; - } - } - - if ($this->collAttributeAvI18ns !== null) { - foreach ($this->collAttributeAvI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AttributeAvPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeAvPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`attribute_id`'; - } - if ($this->isColumnModified(AttributeAvPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute_av` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`attribute_id`': - $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if (!$this->aAttribute->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures()); - } - } - - - if (($retval = AttributeAvPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAttributeAvI18ns !== null) { - foreach ($this->collAttributeAvI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getAttributeId(); - break; - case 2: - return $this->getPosition(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeAv'][$this->getPrimaryKey()] = true; - $keys = AttributeAvPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getAttributeId(), - $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aAttribute) { - $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collAttributeCombinations) { - $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeAvI18ns) { - $result['AttributeAvI18ns'] = $this->collAttributeAvI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setAttributeId($value); - break; - case 2: - $this->setPosition($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AttributeAvPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributeAvPeer::ID)) $criteria->add(AttributeAvPeer::ID, $this->id); - if ($this->isColumnModified(AttributeAvPeer::ATTRIBUTE_ID)) $criteria->add(AttributeAvPeer::ATTRIBUTE_ID, $this->attribute_id); - if ($this->isColumnModified(AttributeAvPeer::POSITION)) $criteria->add(AttributeAvPeer::POSITION, $this->position); - if ($this->isColumnModified(AttributeAvPeer::CREATED_AT)) $criteria->add(AttributeAvPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributeAvPeer::UPDATED_AT)) $criteria->add(AttributeAvPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - $criteria->add(AttributeAvPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of AttributeAv (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setAttributeId($this->getAttributeId()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAttributeCombinations() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCombination($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeAvI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeAvI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return AttributeAv Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AttributeAvPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributeAvPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Attribute object. - * - * @param Attribute $v - * @return AttributeAv The current object (for fluent API support) - * @throws PropelException - */ - public function setAttribute(Attribute $v = null) - { - if ($v === null) { - $this->setAttributeId(NULL); - } else { - $this->setAttributeId($v->getId()); - } - - $this->aAttribute = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Attribute object, it will not be re-added. - if ($v !== null) { - $v->addAttributeAv($this); - } - - - return $this; - } - - - /** - * Get the associated Attribute object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Attribute The associated Attribute object. - * @throws PropelException - */ - public function getAttribute(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { - $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttribute->addAttributeAvs($this); - */ - } - - return $this->aAttribute; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); - } - if ('AttributeAvI18n' == $relationName) { - $this->initAttributeAvI18ns(); - } - } - - /** - * Clears out the collAttributeCombinations collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return AttributeAv The current object (for fluent API support) - * @see addAttributeCombinations() - */ - public function clearAttributeCombinations() - { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCombinations($v = true) - { - $this->collAttributeCombinationsPartial = $v; - } - - /** - * Initializes the collAttributeCombinations collection. - * - * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCombinations($overrideExisting = true) - { - if (null !== $this->collAttributeCombinations && !$overrideExisting) { - return; - } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); - } - - /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this AttributeAv is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - * @throws PropelException - */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - // return empty collection - $this->initAttributeCombinations(); - } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) - ->filterByAttributeAv($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); - - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); - } - } - - $this->collAttributeCombinationsPartial = true; - } - - $collAttributeCombinations->getInternalIterator()->rewind(); - return $collAttributeCombinations; - } - - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { - $collAttributeCombinations[] = $obj; - } - } - } - - $this->collAttributeCombinations = $collAttributeCombinations; - $this->collAttributeCombinationsPartial = false; - } - } - - return $this->collAttributeCombinations; - } - - /** - * Sets a collection of AttributeCombination objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCombinations A Propel collection. - * @param PropelPDO $con Optional connection object - * @return AttributeAv The current object (for fluent API support) - */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) - { - $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); - - foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { - $attributeCombinationRemoved->setAttributeAv(null); - } - - $this->collAttributeCombinations = null; - foreach ($attributeCombinations as $attributeCombination) { - $this->addAttributeCombination($attributeCombination); - } - - $this->collAttributeCombinations = $attributeCombinations; - $this->collAttributeCombinationsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCombination objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCombination objects. - * @throws PropelException - */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttributeAv($this) - ->count($con); - } - - return count($this->collAttributeCombinations); - } - - /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. - * - * @param AttributeCombination $l AttributeCombination - * @return AttributeAv The current object (for fluent API support) - */ - public function addAttributeCombination(AttributeCombination $l) - { - if ($this->collAttributeCombinations === null) { - $this->initAttributeCombinations(); - $this->collAttributeCombinationsPartial = true; - } - if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCombination($l); - } - - return $this; - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. - */ - protected function doAddAttributeCombination($attributeCombination) - { - $this->collAttributeCombinations[]= $attributeCombination; - $attributeCombination->setAttributeAv($this); - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return AttributeAv The current object (for fluent API support) - */ - public function removeAttributeCombination($attributeCombination) - { - if ($this->getAttributeCombinations()->contains($attributeCombination)) { - $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination)); - if (null === $this->attributeCombinationsScheduledForDeletion) { - $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; - $this->attributeCombinationsScheduledForDeletion->clear(); - } - $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; - $attributeCombination->setAttributeAv(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this AttributeAv is new, it will return - * an empty collection; or if this AttributeAv has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in AttributeAv. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this AttributeAv is new, it will return - * an empty collection; or if this AttributeAv has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in AttributeAv. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - /** - * Clears out the collAttributeAvI18ns 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 AttributeAv The current object (for fluent API support) - * @see addAttributeAvI18ns() - */ - public function clearAttributeAvI18ns() - { - $this->collAttributeAvI18ns = null; // important to set this to null since that means it is uninitialized - $this->collAttributeAvI18nsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeAvI18ns collection loaded partially - * - * @return void - */ - public function resetPartialAttributeAvI18ns($v = true) - { - $this->collAttributeAvI18nsPartial = $v; - } - - /** - * Initializes the collAttributeAvI18ns collection. - * - * By default this just sets the collAttributeAvI18ns collection to an empty array (like clearcollAttributeAvI18ns()); - * 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 initAttributeAvI18ns($overrideExisting = true) - { - if (null !== $this->collAttributeAvI18ns && !$overrideExisting) { - return; - } - $this->collAttributeAvI18ns = new PropelObjectCollection(); - $this->collAttributeAvI18ns->setModel('AttributeAvI18n'); - } - - /** - * Gets an array of AttributeAvI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this AttributeAv is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeAvI18n[] List of AttributeAvI18n objects - * @throws PropelException - */ - public function getAttributeAvI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeAvI18nsPartial && !$this->isNew(); - if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeAvI18ns) { - // return empty collection - $this->initAttributeAvI18ns(); - } else { - $collAttributeAvI18ns = AttributeAvI18nQuery::create(null, $criteria) - ->filterByAttributeAv($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeAvI18nsPartial && count($collAttributeAvI18ns)) { - $this->initAttributeAvI18ns(false); - - foreach($collAttributeAvI18ns as $obj) { - if (false == $this->collAttributeAvI18ns->contains($obj)) { - $this->collAttributeAvI18ns->append($obj); - } - } - - $this->collAttributeAvI18nsPartial = true; - } - - $collAttributeAvI18ns->getInternalIterator()->rewind(); - return $collAttributeAvI18ns; - } - - if($partial && $this->collAttributeAvI18ns) { - foreach($this->collAttributeAvI18ns as $obj) { - if($obj->isNew()) { - $collAttributeAvI18ns[] = $obj; - } - } - } - - $this->collAttributeAvI18ns = $collAttributeAvI18ns; - $this->collAttributeAvI18nsPartial = false; - } - } - - return $this->collAttributeAvI18ns; - } - - /** - * Sets a collection of AttributeAvI18n 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 $attributeAvI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return AttributeAv The current object (for fluent API support) - */ - public function setAttributeAvI18ns(PropelCollection $attributeAvI18ns, PropelPDO $con = null) - { - $attributeAvI18nsToDelete = $this->getAttributeAvI18ns(new Criteria(), $con)->diff($attributeAvI18ns); - - $this->attributeAvI18nsScheduledForDeletion = unserialize(serialize($attributeAvI18nsToDelete)); - - foreach ($attributeAvI18nsToDelete as $attributeAvI18nRemoved) { - $attributeAvI18nRemoved->setAttributeAv(null); - } - - $this->collAttributeAvI18ns = null; - foreach ($attributeAvI18ns as $attributeAvI18n) { - $this->addAttributeAvI18n($attributeAvI18n); - } - - $this->collAttributeAvI18ns = $attributeAvI18ns; - $this->collAttributeAvI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeAvI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeAvI18n objects. - * @throws PropelException - */ - public function countAttributeAvI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeAvI18nsPartial && !$this->isNew(); - if (null === $this->collAttributeAvI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeAvI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeAvI18ns()); - } - $query = AttributeAvI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByAttributeAv($this) - ->count($con); - } - - return count($this->collAttributeAvI18ns); - } - - /** - * Method called to associate a AttributeAvI18n object to this object - * through the AttributeAvI18n foreign key attribute. - * - * @param AttributeAvI18n $l AttributeAvI18n - * @return AttributeAv The current object (for fluent API support) - */ - public function addAttributeAvI18n(AttributeAvI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collAttributeAvI18ns === null) { - $this->initAttributeAvI18ns(); - $this->collAttributeAvI18nsPartial = true; - } - if (!in_array($l, $this->collAttributeAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeAvI18n($l); - } - - return $this; - } - - /** - * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to add. - */ - protected function doAddAttributeAvI18n($attributeAvI18n) - { - $this->collAttributeAvI18ns[]= $attributeAvI18n; - $attributeAvI18n->setAttributeAv($this); - } - - /** - * @param AttributeAvI18n $attributeAvI18n The attributeAvI18n object to remove. - * @return AttributeAv The current object (for fluent API support) - */ - public function removeAttributeAvI18n($attributeAvI18n) - { - if ($this->getAttributeAvI18ns()->contains($attributeAvI18n)) { - $this->collAttributeAvI18ns->remove($this->collAttributeAvI18ns->search($attributeAvI18n)); - if (null === $this->attributeAvI18nsScheduledForDeletion) { - $this->attributeAvI18nsScheduledForDeletion = clone $this->collAttributeAvI18ns; - $this->attributeAvI18nsScheduledForDeletion->clear(); - } - $this->attributeAvI18nsScheduledForDeletion[]= clone $attributeAvI18n; - $attributeAvI18n->setAttributeAv(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->attribute_id = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAttributeCombinations) { - foreach ($this->collAttributeCombinations as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeAvI18ns) { - foreach ($this->collAttributeAvI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aAttribute instanceof Persistent) { - $this->aAttribute->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collAttributeCombinations instanceof PropelCollection) { - $this->collAttributeCombinations->clearIterator(); - } - $this->collAttributeCombinations = null; - if ($this->collAttributeAvI18ns instanceof PropelCollection) { - $this->collAttributeAvI18ns->clearIterator(); - } - $this->collAttributeAvI18ns = null; - $this->aAttribute = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeAvPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return AttributeAv The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AttributeAvPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return AttributeAv The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return AttributeAvI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collAttributeAvI18ns) { - foreach ($this->collAttributeAvI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new AttributeAvI18n(); - $translation->setLocale($locale); - } else { - $translation = AttributeAvI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addAttributeAvI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return AttributeAv The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - AttributeAvI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collAttributeAvI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collAttributeAvI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return AttributeAvI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php deleted file mode 100755 index f4d002826..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseAttributeAvI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::ID; - } - - if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) { - $this->aAttributeAv = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return AttributeAvI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = AttributeAvI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = AttributeAvI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AttributeAvI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aAttributeAv !== null && $this->id !== $this->aAttributeAv->getId()) { - $this->aAttributeAv = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::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 = AttributeAvI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aAttributeAv = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeAvI18nQuery::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(AttributeAvI18nPeer::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); - AttributeAvI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttributeAv !== null) { - if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) { - $affectedRows += $this->aAttributeAv->save($con); - } - $this->setAttributeAv($this->aAttributeAv); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeAvI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributeAvI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(AttributeAvI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(AttributeAvI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(AttributeAvI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(AttributeAvI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute_av_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttributeAv !== null) { - if (!$this->aAttributeAv->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttributeAv->getValidationFailures()); - } - } - - - if (($retval = AttributeAvI18nPeer::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 = AttributeAvI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['AttributeAvI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeAvI18n'][serialize($this->getPrimaryKey())] = true; - $keys = AttributeAvI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aAttributeAv) { - $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeAvI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = AttributeAvI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributeAvI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributeAvI18nPeer::ID)) $criteria->add(AttributeAvI18nPeer::ID, $this->id); - if ($this->isColumnModified(AttributeAvI18nPeer::LOCALE)) $criteria->add(AttributeAvI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(AttributeAvI18nPeer::TITLE)) $criteria->add(AttributeAvI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(AttributeAvI18nPeer::DESCRIPTION)) $criteria->add(AttributeAvI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(AttributeAvI18nPeer::CHAPO)) $criteria->add(AttributeAvI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(AttributeAvI18nPeer::POSTSCRIPTUM)) $criteria->add(AttributeAvI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(AttributeAvI18nPeer::DATABASE_NAME); - $criteria->add(AttributeAvI18nPeer::ID, $this->id); - $criteria->add(AttributeAvI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 AttributeAvI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 AttributeAvI18n 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 AttributeAvI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributeAvI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a AttributeAv object. - * - * @param AttributeAv $v - * @return AttributeAvI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setAttributeAv(AttributeAv $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aAttributeAv = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the AttributeAv object, it will not be re-added. - if ($v !== null) { - $v->addAttributeAvI18n($this); - } - - - return $this; - } - - - /** - * Get the associated AttributeAv object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return AttributeAv The associated AttributeAv object. - * @throws PropelException - */ - public function getAttributeAv(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttributeAv === null && ($this->id !== null) && $doQuery) { - $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttributeAv->addAttributeAvI18ns($this); - */ - } - - return $this->aAttributeAv; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aAttributeAv instanceof Persistent) { - $this->aAttributeAv->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aAttributeAv = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeAvI18nPeer::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/BaseAttributeAvI18nPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php deleted file mode 100755 index 078f5a4ae..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (AttributeAvI18nPeer::ID, AttributeAvI18nPeer::LOCALE, AttributeAvI18nPeer::TITLE, AttributeAvI18nPeer::DESCRIPTION, AttributeAvI18nPeer::CHAPO, AttributeAvI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributeAvI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (AttributeAvI18nPeer::ID => 0, AttributeAvI18nPeer::LOCALE => 1, AttributeAvI18nPeer::TITLE => 2, AttributeAvI18nPeer::DESCRIPTION => 3, AttributeAvI18nPeer::CHAPO => 4, AttributeAvI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributeAvI18nPeer::getFieldNames($toType); - $key = isset(AttributeAvI18nPeer::$fieldKeys[$fromType][$name]) ? AttributeAvI18nPeer::$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(AttributeAvI18nPeer::$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, AttributeAvI18nPeer::$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 AttributeAvI18nPeer::$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. AttributeAvI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributeAvI18nPeer::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(AttributeAvI18nPeer::ID); - $criteria->addSelectColumn(AttributeAvI18nPeer::LOCALE); - $criteria->addSelectColumn(AttributeAvI18nPeer::TITLE); - $criteria->addSelectColumn(AttributeAvI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(AttributeAvI18nPeer::CHAPO); - $criteria->addSelectColumn(AttributeAvI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(AttributeAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributeAvI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::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 AttributeAvI18n - * @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 = AttributeAvI18nPeer::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 AttributeAvI18nPeer::populateObjects(AttributeAvI18nPeer::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 directly (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(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributeAvI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::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 AttributeAvI18n $obj A AttributeAvI18n 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->getLocale())); - } // if key === null - AttributeAvI18nPeer::$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 AttributeAvI18n 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 AttributeAvI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 AttributeAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributeAvI18nPeer::$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 AttributeAvI18n 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(AttributeAvI18nPeer::$instances[$key])) { - return AttributeAvI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributeAvI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributeAvI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute_av_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributeAvI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributeAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributeAvI18nPeer::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; - AttributeAvI18nPeer::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 (AttributeAvI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributeAvI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributeAvI18nPeer::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 + AttributeAvI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeAvI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributeAvI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related AttributeAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttributeAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeAvI18nPeer::ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeAvI18n objects pre-filled with their AttributeAv objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeAvI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeAvI18nPeer::DATABASE_NAME); - } - - AttributeAvI18nPeer::addSelectColumns($criteria); - $startcol = AttributeAvI18nPeer::NUM_HYDRATE_COLUMNS; - AttributeAvPeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeAvI18nPeer::ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeAvI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeAvI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeAvI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributeAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributeAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeAvI18n) to $obj2 (AttributeAv) - $obj2->addAttributeAvI18n($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(AttributeAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeAvI18nPeer::ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AttributeAvI18n 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 AttributeAvI18n 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(AttributeAvI18nPeer::DATABASE_NAME); - } - - AttributeAvI18nPeer::addSelectColumns($criteria); - $startcol2 = AttributeAvI18nPeer::NUM_HYDRATE_COLUMNS; - - AttributeAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeAvI18nPeer::ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeAvI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeAvI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeAvI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined AttributeAv rows - - $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributeAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributeAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AttributeAvI18n) to the collection in $obj2 (AttributeAv) - $obj2->addAttributeAvI18n($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(AttributeAvI18nPeer::DATABASE_NAME)->getTable(AttributeAvI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributeAvI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributeAvI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeAvI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributeAvI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AttributeAvI18n or Criteria object. - * - * @param mixed $values Criteria or AttributeAvI18n 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(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AttributeAvI18n object - } - - - // Set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::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 AttributeAvI18n or Criteria object. - * - * @param mixed $values Criteria or AttributeAvI18n 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(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributeAvI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributeAvI18nPeer::ID); - $value = $criteria->remove(AttributeAvI18nPeer::ID); - if ($value) { - $selectCriteria->add(AttributeAvI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeAvI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AttributeAvI18nPeer::LOCALE); - $value = $criteria->remove(AttributeAvI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(AttributeAvI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeAvI18nPeer::TABLE_NAME); - } - - } else { // $values is AttributeAvI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute_av_i18n 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(AttributeAvI18nPeer::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(AttributeAvI18nPeer::TABLE_NAME, $con, AttributeAvI18nPeer::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). - AttributeAvI18nPeer::clearInstancePool(); - AttributeAvI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AttributeAvI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeAvI18n 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(AttributeAvI18nPeer::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. - AttributeAvI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AttributeAvI18n) { // it's a model object - // invalidate the cache for this single object - AttributeAvI18nPeer::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(AttributeAvI18nPeer::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(AttributeAvI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(AttributeAvI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - AttributeAvI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributeAvI18nPeer::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); - AttributeAvI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AttributeAvI18n 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 AttributeAvI18n $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(AttributeAvI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributeAvI18nPeer::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(AttributeAvI18nPeer::DATABASE_NAME, AttributeAvI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return AttributeAvI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = AttributeAvI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(AttributeAvI18nPeer::DATABASE_NAME); - $criteria->add(AttributeAvI18nPeer::ID, $id); - $criteria->add(AttributeAvI18nPeer::LOCALE, $locale); - $v = AttributeAvI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseAttributeAvI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributeAvI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php deleted file mode 100755 index 9fce7d2e2..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAvI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return AttributeAvI18n|AttributeAvI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeAvI18nPeer::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(AttributeAvI18nPeer::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 AttributeAvI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `attribute_av_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 AttributeAvI18n(); - $obj->hydrate($row); - AttributeAvI18nPeer::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 AttributeAvI18n|AttributeAvI18n[]|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|AttributeAvI18n[]|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 AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(AttributeAvI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(AttributeAvI18nPeer::LOCALE, $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 AttributeAvI18nQuery 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(AttributeAvI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(AttributeAvI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByAttributeAv() - * - * @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 AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributeAvI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeAvI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeAvI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related AttributeAv object - * - * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeAv($attributeAv, $comparison = null) - { - if ($attributeAv instanceof AttributeAv) { - return $this - ->addUsingAlias(AttributeAvI18nPeer::ID, $attributeAv->getId(), $comparison); - } elseif ($attributeAv instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeAvI18nPeer::ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function joinAttributeAv($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeAv'); - } - - return $this; - } - - /** - * Use the AttributeAv relation AttributeAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query - */ - public function useAttributeAvQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinAttributeAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); - } - - /** - * Exclude object from result - * - * @param AttributeAvI18n $attributeAvI18n Object to remove from the list of results - * - * @return AttributeAvI18nQuery The current query, for fluid interface - */ - public function prune($attributeAvI18n = null) - { - if ($attributeAvI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(AttributeAvI18nPeer::ID), $attributeAvI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(AttributeAvI18nPeer::LOCALE), $attributeAvI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php b/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php deleted file mode 100755 index ceb4a41c1..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAvPeer.php +++ /dev/null @@ -1,1044 +0,0 @@ - array ('Id', 'AttributeId', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeId', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AttributeAvPeer::ID, AttributeAvPeer::ATTRIBUTE_ID, AttributeAvPeer::POSITION, AttributeAvPeer::CREATED_AT, AttributeAvPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributeAvPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AttributeId' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeId' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (AttributeAvPeer::ID => 0, AttributeAvPeer::ATTRIBUTE_ID => 1, AttributeAvPeer::POSITION => 2, AttributeAvPeer::CREATED_AT => 3, AttributeAvPeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_ID' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributeAvPeer::getFieldNames($toType); - $key = isset(AttributeAvPeer::$fieldKeys[$fromType][$name]) ? AttributeAvPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeAvPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AttributeAvPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AttributeAvPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AttributeAvPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributeAvPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AttributeAvPeer::ID); - $criteria->addSelectColumn(AttributeAvPeer::ATTRIBUTE_ID); - $criteria->addSelectColumn(AttributeAvPeer::POSITION); - $criteria->addSelectColumn(AttributeAvPeer::CREATED_AT); - $criteria->addSelectColumn(AttributeAvPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.attribute_id'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return AttributeAv - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AttributeAvPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AttributeAvPeer::populateObjects(AttributeAvPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributeAvPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param AttributeAv $obj A AttributeAv object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AttributeAvPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A AttributeAv object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof AttributeAv) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeAv object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributeAvPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return AttributeAv Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AttributeAvPeer::$instances[$key])) { - return AttributeAvPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributeAvPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributeAvPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute_av - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AttributeCombinationPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCombinationPeer::clearInstancePool(); - // Invalidate objects in AttributeAvI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeAvI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributeAvPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributeAvPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AttributeAvPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AttributeAv object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributeAvPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AttributeAvPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeAvPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributeAvPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeAv objects pre-filled with their Attribute objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeAv objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - } - - AttributeAvPeer::addSelectColumns($criteria); - $startcol = AttributeAvPeer::NUM_HYDRATE_COLUMNS; - AttributePeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeAvPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeAvPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeAvPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeAv) to $obj2 (Attribute) - $obj2->addAttributeAv($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AttributeAv objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeAv objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - } - - AttributeAvPeer::addSelectColumns($criteria); - $startcol2 = AttributeAvPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeAvPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeAvPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeAvPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeAvPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AttributeAv) to the collection in $obj2 (Attribute) - $obj2->addAttributeAv($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AttributeAvPeer::DATABASE_NAME)->getTable(AttributeAvPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributeAvPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributeAvPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeAvTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributeAvPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AttributeAv or Criteria object. - * - * @param mixed $values Criteria or AttributeAv object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AttributeAv object - } - - if ($criteria->containsKey(AttributeAvPeer::ID) && $criteria->keyContainsValue(AttributeAvPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeAvPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a AttributeAv or Criteria object. - * - * @param mixed $values Criteria or AttributeAv object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributeAvPeer::ID); - $value = $criteria->remove(AttributeAvPeer::ID); - if ($value) { - $selectCriteria->add(AttributeAvPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeAvPeer::TABLE_NAME); - } - - } else { // $values is AttributeAv object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute_av table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AttributeAvPeer::TABLE_NAME, $con, AttributeAvPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AttributeAvPeer::clearInstancePool(); - AttributeAvPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AttributeAv or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeAv object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AttributeAvPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AttributeAv) { // it's a model object - // invalidate the cache for this single object - AttributeAvPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - $criteria->add(AttributeAvPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AttributeAvPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributeAvPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AttributeAvPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AttributeAv object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param AttributeAv $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AttributeAvPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributeAvPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AttributeAvPeer::DATABASE_NAME, AttributeAvPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return AttributeAv - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AttributeAvPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - $criteria->add(AttributeAvPeer::ID, $pk); - - $v = AttributeAvPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return AttributeAv[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AttributeAvPeer::DATABASE_NAME); - $criteria->add(AttributeAvPeer::ID, $pks, Criteria::IN); - $objs = AttributeAvPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAttributeAvPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributeAvPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php b/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php deleted file mode 100755 index 83bf5d6ac..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeAvQuery.php +++ /dev/null @@ -1,836 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeAvPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AttributeAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeAv A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeAv A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `attribute_id`, `position`, `created_at`, `updated_at` FROM `attribute_av` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeAv(); - $obj->hydrate($row); - AttributeAvPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeAv|AttributeAv[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|AttributeAv[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AttributeAvPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AttributeAvPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributeAvPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the attribute_id column - * - * Example usage: - * - * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 - * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 - * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 - * - * - * @see filterByAttribute() - * - * @param mixed $attributeId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByAttributeId($attributeId = null, $comparison = null) - { - if (is_array($attributeId)) { - $useMinMax = false; - if (isset($attributeId['min'])) { - $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attributeId, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(AttributeAvPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(AttributeAvPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Attribute object - * - * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttribute($attribute, $comparison = null) - { - if ($attribute instanceof Attribute) { - return $this - ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeAvPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Attribute relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Attribute'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Attribute'); - } - - return $this; - } - - /** - * Use the Attribute relation Attribute object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query - */ - public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttribute($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); - } - - /** - * Filter the query by a related AttributeCombination object - * - * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeCombination($attributeCombination, $comparison = null) - { - if ($attributeCombination instanceof AttributeCombination) { - return $this - ->addUsingAlias(AttributeAvPeer::ID, $attributeCombination->getAttributeAvId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { - return $this - ->useAttributeCombinationQuery() - ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCombination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCombination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCombination'); - } - - return $this; - } - - /** - * Use the AttributeCombination relation AttributeCombination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query - */ - public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery'); - } - - /** - * Filter the query by a related AttributeAvI18n object - * - * @param AttributeAvI18n|PropelObjectCollection $attributeAvI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeAvI18n($attributeAvI18n, $comparison = null) - { - if ($attributeAvI18n instanceof AttributeAvI18n) { - return $this - ->addUsingAlias(AttributeAvPeer::ID, $attributeAvI18n->getId(), $comparison); - } elseif ($attributeAvI18n instanceof PropelObjectCollection) { - return $this - ->useAttributeAvI18nQuery() - ->filterByPrimaryKeys($attributeAvI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeAvI18n() only accepts arguments of type AttributeAvI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeAvI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function joinAttributeAvI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeAvI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeAvI18n'); - } - - return $this; - } - - /** - * Use the AttributeAvI18n relation AttributeAvI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeAvI18nQuery A secondary query class using the current class as primary query - */ - public function useAttributeAvI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinAttributeAvI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', '\Thelia\Model\AttributeAvI18nQuery'); - } - - /** - * Exclude object from result - * - * @param AttributeAv $attributeAv Object to remove from the list of results - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function prune($attributeAv = null) - { - if ($attributeAv) { - $this->addUsingAlias(AttributeAvPeer::ID, $attributeAv->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AttributeAvPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeAvPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeAvPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AttributeAvPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeAvPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeAvPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; - - return $this - ->joinAttributeAvI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeAvQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('AttributeAvI18n'); - $this->with['AttributeAvI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeAvI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAvI18n', 'Thelia\Model\AttributeAvI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategory.php b/core/lib/Thelia/Model/om/BaseAttributeCategory.php deleted file mode 100755 index 4245e0b83..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCategory.php +++ /dev/null @@ -1,1287 +0,0 @@ -id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [attribute_id] column value. - * - * @return int - */ - public function getAttributeId() - { - return $this->attribute_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AttributeCategory The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributeCategoryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return AttributeCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = AttributeCategoryPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [attribute_id] column. - * - * @param int $v new value - * @return AttributeCategory The current object (for fluent API support) - */ - public function setAttributeId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->attribute_id !== $v) { - $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeCategoryPeer::ATTRIBUTE_ID; - } - - if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { - $this->aAttribute = null; - } - - - return $this; - } // setAttributeId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeCategory The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AttributeCategoryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeCategory The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AttributeCategoryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->attribute_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AttributeCategory object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { - $this->aAttribute = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AttributeCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCategory = null; - $this->aAttribute = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeCategoryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AttributeCategoryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aAttribute !== null) { - if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { - $affectedRows += $this->aAttribute->save($con); - } - $this->setAttribute($this->aAttribute); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AttributeCategoryPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCategoryPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeCategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributeCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(AttributeCategoryPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`attribute_id`'; - } - if ($this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute_category` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`attribute_id`': - $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aAttribute !== null) { - if (!$this->aAttribute->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures()); - } - } - - - if (($retval = AttributeCategoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCategoryId(); - break; - case 2: - return $this->getAttributeId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeCategory'][$this->getPrimaryKey()] = true; - $keys = AttributeCategoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getAttributeId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aAttribute) { - $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCategoryId($value); - break; - case 2: - $this->setAttributeId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AttributeCategoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAttributeId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributeCategoryPeer::ID)) $criteria->add(AttributeCategoryPeer::ID, $this->id); - if ($this->isColumnModified(AttributeCategoryPeer::CATEGORY_ID)) $criteria->add(AttributeCategoryPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(AttributeCategoryPeer::ATTRIBUTE_ID)) $criteria->add(AttributeCategoryPeer::ATTRIBUTE_ID, $this->attribute_id); - if ($this->isColumnModified(AttributeCategoryPeer::CREATED_AT)) $criteria->add(AttributeCategoryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributeCategoryPeer::UPDATED_AT)) $criteria->add(AttributeCategoryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - $criteria->add(AttributeCategoryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of AttributeCategory (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setAttributeId($this->getAttributeId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return AttributeCategory Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AttributeCategoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributeCategoryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return AttributeCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addAttributeCategorys($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Attribute object. - * - * @param Attribute $v - * @return AttributeCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setAttribute(Attribute $v = null) - { - if ($v === null) { - $this->setAttributeId(NULL); - } else { - $this->setAttributeId($v->getId()); - } - - $this->aAttribute = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Attribute object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Attribute object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Attribute The associated Attribute object. - * @throws PropelException - */ - public function getAttribute(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { - $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttribute->addAttributeCategorys($this); - */ - } - - return $this->aAttribute; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->category_id = null; - $this->attribute_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aAttribute instanceof Persistent) { - $this->aAttribute->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCategory = null; - $this->aAttribute = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeCategoryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return AttributeCategory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AttributeCategoryPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php deleted file mode 100755 index 118b82370..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryPeer.php +++ /dev/null @@ -1,1423 +0,0 @@ - array ('Id', 'CategoryId', 'AttributeId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'attributeId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AttributeCategoryPeer::ID, AttributeCategoryPeer::CATEGORY_ID, AttributeCategoryPeer::ATTRIBUTE_ID, AttributeCategoryPeer::CREATED_AT, AttributeCategoryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'ATTRIBUTE_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'attribute_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributeCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'AttributeId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'attributeId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (AttributeCategoryPeer::ID => 0, AttributeCategoryPeer::CATEGORY_ID => 1, AttributeCategoryPeer::ATTRIBUTE_ID => 2, AttributeCategoryPeer::CREATED_AT => 3, AttributeCategoryPeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'ATTRIBUTE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'attribute_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributeCategoryPeer::getFieldNames($toType); - $key = isset(AttributeCategoryPeer::$fieldKeys[$fromType][$name]) ? AttributeCategoryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeCategoryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AttributeCategoryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AttributeCategoryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AttributeCategoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributeCategoryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AttributeCategoryPeer::ID); - $criteria->addSelectColumn(AttributeCategoryPeer::CATEGORY_ID); - $criteria->addSelectColumn(AttributeCategoryPeer::ATTRIBUTE_ID); - $criteria->addSelectColumn(AttributeCategoryPeer::CREATED_AT); - $criteria->addSelectColumn(AttributeCategoryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.attribute_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return AttributeCategory - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AttributeCategoryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AttributeCategoryPeer::populateObjects(AttributeCategoryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributeCategoryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param AttributeCategory $obj A AttributeCategory object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AttributeCategoryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A AttributeCategory object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof AttributeCategory) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributeCategoryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return AttributeCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AttributeCategoryPeer::$instances[$key])) { - return AttributeCategoryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributeCategoryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributeCategoryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute_category - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributeCategoryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AttributeCategoryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AttributeCategory object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeCategoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributeCategoryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeCategory objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - } - - AttributeCategoryPeer::addSelectColumns($criteria); - $startcol = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeCategory) to $obj2 (Category) - $obj2->addAttributeCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCategory objects pre-filled with their Attribute objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - } - - AttributeCategoryPeer::addSelectColumns($criteria); - $startcol = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - AttributePeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeCategory) to $obj2 (Attribute) - $obj2->addAttributeCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AttributeCategory objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - } - - AttributeCategoryPeer::addSelectColumns($criteria); - $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + AttributePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Category) - $obj2->addAttributeCategory($obj1); - } // if joined row not null - - // Add objects for joined Attribute rows - - $key3 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = AttributePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = AttributePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - AttributePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (AttributeCategory) to the collection in $obj3 (Attribute) - $obj3->addAttributeCategory($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeCategory objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - } - - AttributeCategoryPeer::addSelectColumns($criteria); - $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCategoryPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Attribute) - $obj2->addAttributeCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCategory objects pre-filled with all related objects except Attribute. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - } - - AttributeCategoryPeer::addSelectColumns($criteria); - $startcol2 = AttributeCategoryPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AttributeCategory) to the collection in $obj2 (Category) - $obj2->addAttributeCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AttributeCategoryPeer::DATABASE_NAME)->getTable(AttributeCategoryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributeCategoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributeCategoryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeCategoryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributeCategoryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AttributeCategory or Criteria object. - * - * @param mixed $values Criteria or AttributeCategory object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AttributeCategory object - } - - if ($criteria->containsKey(AttributeCategoryPeer::ID) && $criteria->keyContainsValue(AttributeCategoryPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCategoryPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a AttributeCategory or Criteria object. - * - * @param mixed $values Criteria or AttributeCategory object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributeCategoryPeer::ID); - $value = $criteria->remove(AttributeCategoryPeer::ID); - if ($value) { - $selectCriteria->add(AttributeCategoryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeCategoryPeer::TABLE_NAME); - } - - } else { // $values is AttributeCategory object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute_category table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AttributeCategoryPeer::TABLE_NAME, $con, AttributeCategoryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AttributeCategoryPeer::clearInstancePool(); - AttributeCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AttributeCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeCategory object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AttributeCategoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AttributeCategory) { // it's a model object - // invalidate the cache for this single object - AttributeCategoryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - $criteria->add(AttributeCategoryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AttributeCategoryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributeCategoryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AttributeCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AttributeCategory object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param AttributeCategory $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AttributeCategoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributeCategoryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AttributeCategoryPeer::DATABASE_NAME, AttributeCategoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return AttributeCategory - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AttributeCategoryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - $criteria->add(AttributeCategoryPeer::ID, $pk); - - $v = AttributeCategoryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return AttributeCategory[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AttributeCategoryPeer::DATABASE_NAME); - $criteria->add(AttributeCategoryPeer::ID, $pks, Criteria::IN); - $objs = AttributeCategoryPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAttributeCategoryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributeCategoryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php deleted file mode 100755 index f9deef20a..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCategoryQuery.php +++ /dev/null @@ -1,704 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeCategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AttributeCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeCategory A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeCategory A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `category_id`, `attribute_id`, `created_at`, `updated_at` FROM `attribute_category` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeCategory(); - $obj->hydrate($row); - AttributeCategoryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeCategory|AttributeCategory[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|AttributeCategory[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AttributeCategoryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AttributeCategoryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributeCategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the attribute_id column - * - * Example usage: - * - * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 - * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 - * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 - * - * - * @see filterByAttribute() - * - * @param mixed $attributeId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByAttributeId($attributeId = null, $comparison = null) - { - if (is_array($attributeId)) { - $useMinMax = false; - if (isset($attributeId['min'])) { - $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attributeId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Attribute object - * - * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttribute($attribute, $comparison = null) - { - if ($attribute instanceof Attribute) { - return $this - ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCategoryPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Attribute relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Attribute'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Attribute'); - } - - return $this; - } - - /** - * Use the Attribute relation Attribute object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query - */ - public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttribute($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); - } - - /** - * Exclude object from result - * - * @param AttributeCategory $attributeCategory Object to remove from the list of results - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function prune($attributeCategory = null) - { - if ($attributeCategory) { - $this->addUsingAlias(AttributeCategoryPeer::ID, $attributeCategory->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCategoryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCategoryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AttributeCategoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCategoryPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombination.php b/core/lib/Thelia/Model/om/BaseAttributeCombination.php deleted file mode 100755 index 523ff9d1e..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCombination.php +++ /dev/null @@ -1,1442 +0,0 @@ -id; - } - - /** - * Get the [attribute_id] column value. - * - * @return int - */ - public function getAttributeId() - { - return $this->attribute_id; - } - - /** - * Get the [combination_id] column value. - * - * @return int - */ - public function getCombinationId() - { - return $this->combination_id; - } - - /** - * Get the [attribute_av_id] column value. - * - * @return int - */ - public function getAttributeAvId() - { - return $this->attribute_av_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AttributeCombination The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributeCombinationPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [attribute_id] column. - * - * @param int $v new value - * @return AttributeCombination The current object (for fluent API support) - */ - public function setAttributeId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->attribute_id !== $v) { - $this->attribute_id = $v; - $this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_ID; - } - - if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { - $this->aAttribute = null; - } - - - return $this; - } // setAttributeId() - - /** - * Set the value of [combination_id] column. - * - * @param int $v new value - * @return AttributeCombination The current object (for fluent API support) - */ - public function setCombinationId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->combination_id !== $v) { - $this->combination_id = $v; - $this->modifiedColumns[] = AttributeCombinationPeer::COMBINATION_ID; - } - - if ($this->aCombination !== null && $this->aCombination->getId() !== $v) { - $this->aCombination = null; - } - - - return $this; - } // setCombinationId() - - /** - * Set the value of [attribute_av_id] column. - * - * @param int $v new value - * @return AttributeCombination The current object (for fluent API support) - */ - public function setAttributeAvId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->attribute_av_id !== $v) { - $this->attribute_av_id = $v; - $this->modifiedColumns[] = AttributeCombinationPeer::ATTRIBUTE_AV_ID; - } - - if ($this->aAttributeAv !== null && $this->aAttributeAv->getId() !== $v) { - $this->aAttributeAv = null; - } - - - return $this; - } // setAttributeAvId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeCombination The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = AttributeCombinationPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return AttributeCombination The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = AttributeCombinationPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->attribute_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->combination_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->attribute_av_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AttributeCombination object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aAttribute !== null && $this->attribute_id !== $this->aAttribute->getId()) { - $this->aAttribute = null; - } - if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) { - $this->aCombination = null; - } - if ($this->aAttributeAv !== null && $this->attribute_av_id !== $this->aAttributeAv->getId()) { - $this->aAttributeAv = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = AttributeCombinationPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aAttribute = null; - $this->aAttributeAv = null; - $this->aCombination = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeCombinationQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AttributeCombinationPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { - $affectedRows += $this->aAttribute->save($con); - } - $this->setAttribute($this->aAttribute); - } - - if ($this->aAttributeAv !== null) { - if ($this->aAttributeAv->isModified() || $this->aAttributeAv->isNew()) { - $affectedRows += $this->aAttributeAv->save($con); - } - $this->setAttributeAv($this->aAttributeAv); - } - - if ($this->aCombination !== null) { - if ($this->aCombination->isModified() || $this->aCombination->isNew()) { - $affectedRows += $this->aCombination->save($con); - } - $this->setCombination($this->aCombination); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AttributeCombinationPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AttributeCombinationPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeCombinationPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_ID)) { - $modifiedColumns[':p' . $index++] = '`attribute_id`'; - } - if ($this->isColumnModified(AttributeCombinationPeer::COMBINATION_ID)) { - $modifiedColumns[':p' . $index++] = '`combination_id`'; - } - if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_AV_ID)) { - $modifiedColumns[':p' . $index++] = '`attribute_av_id`'; - } - if ($this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute_combination` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`attribute_id`': - $stmt->bindValue($identifier, $this->attribute_id, PDO::PARAM_INT); - break; - case '`combination_id`': - $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT); - break; - case '`attribute_av_id`': - $stmt->bindValue($identifier, $this->attribute_av_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if (!$this->aAttribute->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures()); - } - } - - if ($this->aAttributeAv !== null) { - if (!$this->aAttributeAv->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttributeAv->getValidationFailures()); - } - } - - if ($this->aCombination !== null) { - if (!$this->aCombination->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCombination->getValidationFailures()); - } - } - - - if (($retval = AttributeCombinationPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeCombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getAttributeId(); - break; - case 2: - return $this->getCombinationId(); - break; - case 3: - return $this->getAttributeAvId(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeCombination'][serialize($this->getPrimaryKey())] = true; - $keys = AttributeCombinationPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getAttributeId(), - $keys[2] => $this->getCombinationId(), - $keys[3] => $this->getAttributeAvId(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aAttribute) { - $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aAttributeAv) { - $result['AttributeAv'] = $this->aAttributeAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCombination) { - $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeCombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setAttributeId($value); - break; - case 2: - $this->setCombinationId($value); - break; - case 3: - $this->setAttributeAvId($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = AttributeCombinationPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCombinationId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAttributeAvId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributeCombinationPeer::ID)) $criteria->add(AttributeCombinationPeer::ID, $this->id); - if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_ID)) $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $this->attribute_id); - if ($this->isColumnModified(AttributeCombinationPeer::COMBINATION_ID)) $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $this->combination_id); - if ($this->isColumnModified(AttributeCombinationPeer::ATTRIBUTE_AV_ID)) $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $this->attribute_av_id); - if ($this->isColumnModified(AttributeCombinationPeer::CREATED_AT)) $criteria->add(AttributeCombinationPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AttributeCombinationPeer::UPDATED_AT)) $criteria->add(AttributeCombinationPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME); - $criteria->add(AttributeCombinationPeer::ID, $this->id); - $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $this->attribute_id); - $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $this->combination_id); - $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $this->attribute_av_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getAttributeId(); - $pks[2] = $this->getCombinationId(); - $pks[3] = $this->getAttributeAvId(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setId($keys[0]); - $this->setAttributeId($keys[1]); - $this->setCombinationId($keys[2]); - $this->setAttributeAvId($keys[3]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getAttributeId()) && (null === $this->getCombinationId()) && (null === $this->getAttributeAvId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of AttributeCombination (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setAttributeId($this->getAttributeId()); - $copyObj->setCombinationId($this->getCombinationId()); - $copyObj->setAttributeAvId($this->getAttributeAvId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return AttributeCombination Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return AttributeCombinationPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributeCombinationPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Attribute object. - * - * @param Attribute $v - * @return AttributeCombination The current object (for fluent API support) - * @throws PropelException - */ - public function setAttribute(Attribute $v = null) - { - if ($v === null) { - $this->setAttributeId(NULL); - } else { - $this->setAttributeId($v->getId()); - } - - $this->aAttribute = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Attribute object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCombination($this); - } - - - return $this; - } - - - /** - * Get the associated Attribute object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Attribute The associated Attribute object. - * @throws PropelException - */ - public function getAttribute(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttribute === null && ($this->attribute_id !== null) && $doQuery) { - $this->aAttribute = AttributeQuery::create()->findPk($this->attribute_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttribute->addAttributeCombinations($this); - */ - } - - return $this->aAttribute; - } - - /** - * Declares an association between this object and a AttributeAv object. - * - * @param AttributeAv $v - * @return AttributeCombination The current object (for fluent API support) - * @throws PropelException - */ - public function setAttributeAv(AttributeAv $v = null) - { - if ($v === null) { - $this->setAttributeAvId(NULL); - } else { - $this->setAttributeAvId($v->getId()); - } - - $this->aAttributeAv = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the AttributeAv object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCombination($this); - } - - - return $this; - } - - - /** - * Get the associated AttributeAv object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return AttributeAv The associated AttributeAv object. - * @throws PropelException - */ - public function getAttributeAv(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttributeAv === null && ($this->attribute_av_id !== null) && $doQuery) { - $this->aAttributeAv = AttributeAvQuery::create()->findPk($this->attribute_av_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttributeAv->addAttributeCombinations($this); - */ - } - - return $this->aAttributeAv; - } - - /** - * Declares an association between this object and a Combination object. - * - * @param Combination $v - * @return AttributeCombination The current object (for fluent API support) - * @throws PropelException - */ - public function setCombination(Combination $v = null) - { - if ($v === null) { - $this->setCombinationId(NULL); - } else { - $this->setCombinationId($v->getId()); - } - - $this->aCombination = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Combination object, it will not be re-added. - if ($v !== null) { - $v->addAttributeCombination($this); - } - - - return $this; - } - - - /** - * Get the associated Combination object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Combination The associated Combination object. - * @throws PropelException - */ - public function getCombination(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCombination === null && ($this->combination_id !== null) && $doQuery) { - $this->aCombination = CombinationQuery::create()->findPk($this->combination_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCombination->addAttributeCombinations($this); - */ - } - - return $this->aCombination; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->attribute_id = null; - $this->combination_id = null; - $this->attribute_av_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aAttribute instanceof Persistent) { - $this->aAttribute->clearAllReferences($deep); - } - if ($this->aAttributeAv instanceof Persistent) { - $this->aAttributeAv->clearAllReferences($deep); - } - if ($this->aCombination instanceof Persistent) { - $this->aCombination->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aAttribute = null; - $this->aAttributeAv = null; - $this->aCombination = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeCombinationPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return AttributeCombination The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AttributeCombinationPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php deleted file mode 100755 index b98d542d5..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationPeer.php +++ /dev/null @@ -1,1783 +0,0 @@ - array ('Id', 'AttributeId', 'CombinationId', 'AttributeAvId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'attributeId', 'combinationId', 'attributeAvId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID, AttributeCombinationPeer::ATTRIBUTE_ID, AttributeCombinationPeer::COMBINATION_ID, AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeCombinationPeer::CREATED_AT, AttributeCombinationPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ATTRIBUTE_ID', 'COMBINATION_ID', 'ATTRIBUTE_AV_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'attribute_id', 'combination_id', 'attribute_av_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributeCombinationPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AttributeId' => 1, 'CombinationId' => 2, 'AttributeAvId' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'attributeId' => 1, 'combinationId' => 2, 'attributeAvId' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (AttributeCombinationPeer::ID => 0, AttributeCombinationPeer::ATTRIBUTE_ID => 1, AttributeCombinationPeer::COMBINATION_ID => 2, AttributeCombinationPeer::ATTRIBUTE_AV_ID => 3, AttributeCombinationPeer::CREATED_AT => 4, AttributeCombinationPeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ATTRIBUTE_ID' => 1, 'COMBINATION_ID' => 2, 'ATTRIBUTE_AV_ID' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'attribute_id' => 1, 'combination_id' => 2, 'attribute_av_id' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributeCombinationPeer::getFieldNames($toType); - $key = isset(AttributeCombinationPeer::$fieldKeys[$fromType][$name]) ? AttributeCombinationPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributeCombinationPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AttributeCombinationPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AttributeCombinationPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AttributeCombinationPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributeCombinationPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AttributeCombinationPeer::ID); - $criteria->addSelectColumn(AttributeCombinationPeer::ATTRIBUTE_ID); - $criteria->addSelectColumn(AttributeCombinationPeer::COMBINATION_ID); - $criteria->addSelectColumn(AttributeCombinationPeer::ATTRIBUTE_AV_ID); - $criteria->addSelectColumn(AttributeCombinationPeer::CREATED_AT); - $criteria->addSelectColumn(AttributeCombinationPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.attribute_id'); - $criteria->addSelectColumn($alias . '.combination_id'); - $criteria->addSelectColumn($alias . '.attribute_av_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return AttributeCombination - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AttributeCombinationPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AttributeCombinationPeer::populateObjects(AttributeCombinationPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributeCombinationPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param AttributeCombination $obj A AttributeCombination object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getAttributeId(), (string) $obj->getCombinationId(), (string) $obj->getAttributeAvId())); - } // if key === null - AttributeCombinationPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A AttributeCombination object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof AttributeCombination) { - $key = serialize(array((string) $value->getId(), (string) $value->getAttributeId(), (string) $value->getCombinationId(), (string) $value->getAttributeAvId())); - } elseif (is_array($value) && count($value) === 4) { - // assume we've been passed a primary key - $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2], (string) $value[3])); - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or AttributeCombination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributeCombinationPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return AttributeCombination Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AttributeCombinationPeer::$instances[$key])) { - return AttributeCombinationPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributeCombinationPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributeCombinationPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute_combination - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null && $row[$startcol + 2] === null && $row[$startcol + 3] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1], (string) $row[$startcol + 2], (string) $row[$startcol + 3])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (int) $row[$startcol + 1], (int) $row[$startcol + 2], (int) $row[$startcol + 3]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributeCombinationPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AttributeCombinationPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AttributeCombination object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeCombinationPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributeCombinationPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related AttributeAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttributeAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Combination table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCombination(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with their Attribute objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - AttributePeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeCombination) to $obj2 (Attribute) - $obj2->addAttributeCombination($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with their AttributeAv objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - AttributeAvPeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributeAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributeAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeCombination) to $obj2 (AttributeAv) - $obj2->addAttributeCombination($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with their Combination objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - CombinationPeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CombinationPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CombinationPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CombinationPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeCombination) to $obj2 (Combination) - $obj2->addAttributeCombination($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AttributeCombination objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - AttributeAvPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + AttributeAvPeer::NUM_HYDRATE_COLUMNS; - - CombinationPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + CombinationPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute) - $obj2->addAttributeCombination($obj1); - } // if joined row not null - - // Add objects for joined AttributeAv rows - - $key3 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = AttributeAvPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - AttributeAvPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj3 (AttributeAv) - $obj3->addAttributeCombination($obj1); - } // if joined row not null - - // Add objects for joined Combination rows - - $key4 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = CombinationPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = CombinationPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - CombinationPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj4 (Combination) - $obj4->addAttributeCombination($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related AttributeAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptAttributeAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Combination table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCombination(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeCombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with all related objects except Attribute. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - - AttributeAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributeAvPeer::NUM_HYDRATE_COLUMNS; - - CombinationPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CombinationPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined AttributeAv rows - - $key2 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributeAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributeAvPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj2 (AttributeAv) - $obj2->addAttributeCombination($obj1); - - } // if joined row is not null - - // Add objects for joined Combination rows - - $key3 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CombinationPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CombinationPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CombinationPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj3 (Combination) - $obj3->addAttributeCombination($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with all related objects except AttributeAv. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptAttributeAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - CombinationPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CombinationPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute) - $obj2->addAttributeCombination($obj1); - - } // if joined row is not null - - // Add objects for joined Combination rows - - $key3 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CombinationPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CombinationPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CombinationPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj3 (Combination) - $obj3->addAttributeCombination($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of AttributeCombination objects pre-filled with all related objects except Combination. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeCombination objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - } - - AttributeCombinationPeer::addSelectColumns($criteria); - $startcol2 = AttributeCombinationPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - AttributeAvPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + AttributeAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_ID, AttributePeer::ID, $join_behavior); - - $criteria->addJoin(AttributeCombinationPeer::ATTRIBUTE_AV_ID, AttributeAvPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeCombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeCombinationPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeCombinationPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj2 (Attribute) - $obj2->addAttributeCombination($obj1); - - } // if joined row is not null - - // Add objects for joined AttributeAv rows - - $key3 = AttributeAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = AttributeAvPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = AttributeAvPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - AttributeAvPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (AttributeCombination) to the collection in $obj3 (AttributeAv) - $obj3->addAttributeCombination($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AttributeCombinationPeer::DATABASE_NAME)->getTable(AttributeCombinationPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributeCombinationPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributeCombinationPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeCombinationTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributeCombinationPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AttributeCombination or Criteria object. - * - * @param mixed $values Criteria or AttributeCombination object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AttributeCombination object - } - - if ($criteria->containsKey(AttributeCombinationPeer::ID) && $criteria->keyContainsValue(AttributeCombinationPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributeCombinationPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a AttributeCombination or Criteria object. - * - * @param mixed $values Criteria or AttributeCombination object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributeCombinationPeer::ID); - $value = $criteria->remove(AttributeCombinationPeer::ID); - if ($value) { - $selectCriteria->add(AttributeCombinationPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AttributeCombinationPeer::ATTRIBUTE_ID); - $value = $criteria->remove(AttributeCombinationPeer::ATTRIBUTE_ID); - if ($value) { - $selectCriteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AttributeCombinationPeer::COMBINATION_ID); - $value = $criteria->remove(AttributeCombinationPeer::COMBINATION_ID); - if ($value) { - $selectCriteria->add(AttributeCombinationPeer::COMBINATION_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AttributeCombinationPeer::ATTRIBUTE_AV_ID); - $value = $criteria->remove(AttributeCombinationPeer::ATTRIBUTE_AV_ID); - if ($value) { - $selectCriteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeCombinationPeer::TABLE_NAME); - } - - } else { // $values is AttributeCombination object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute_combination table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AttributeCombinationPeer::TABLE_NAME, $con, AttributeCombinationPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AttributeCombinationPeer::clearInstancePool(); - AttributeCombinationPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AttributeCombination or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeCombination object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AttributeCombinationPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AttributeCombination) { // it's a model object - // invalidate the cache for this single object - AttributeCombinationPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(AttributeCombinationPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::COMBINATION_ID, $value[2])); - $criterion->addAnd($criteria->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $value[3])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - AttributeCombinationPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributeCombinationPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AttributeCombinationPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AttributeCombination object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param AttributeCombination $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AttributeCombinationPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributeCombinationPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AttributeCombinationPeer::DATABASE_NAME, AttributeCombinationPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param int $attribute_id - * @param int $combination_id - * @param int $attribute_av_id - * @param PropelPDO $con - * @return AttributeCombination - */ - public static function retrieveByPK($id, $attribute_id, $combination_id, $attribute_av_id, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $attribute_id, (string) $combination_id, (string) $attribute_av_id)); - if (null !== ($obj = AttributeCombinationPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(AttributeCombinationPeer::DATABASE_NAME); - $criteria->add(AttributeCombinationPeer::ID, $id); - $criteria->add(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute_id); - $criteria->add(AttributeCombinationPeer::COMBINATION_ID, $combination_id); - $criteria->add(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attribute_av_id); - $v = AttributeCombinationPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseAttributeCombinationPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributeCombinationPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php b/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php deleted file mode 100755 index 4366cc0bb..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeCombinationQuery.php +++ /dev/null @@ -1,845 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34, 56, 78), $con); - * - * - * @param array $key Primary key to use for the query - A Primary key composition: [$id, $attribute_id, $combination_id, $attribute_av_id] - * @param PropelPDO $con an optional connection object - * - * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeCombinationPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AttributeCombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeCombination A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `attribute_id`, `combination_id`, `attribute_av_id`, `created_at`, `updated_at` FROM `attribute_combination` WHERE `id` = :p0 AND `attribute_id` = :p1 AND `combination_id` = :p2 AND `attribute_av_id` = :p3'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); - $stmt->bindValue(':p3', $key[3], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new AttributeCombination(); - $obj->hydrate($row); - AttributeCombinationPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2], (string) $key[3]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return AttributeCombination|AttributeCombination[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|AttributeCombination[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(AttributeCombinationPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $key[2], Criteria::EQUAL); - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(AttributeCombinationPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AttributeCombinationPeer::COMBINATION_ID, $key[2], Criteria::EQUAL); - $cton0->addAnd($cton2); - $cton3 = $this->getNewCriterion(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $key[3], Criteria::EQUAL); - $cton0->addAnd($cton3); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the attribute_id column - * - * Example usage: - * - * $query->filterByAttributeId(1234); // WHERE attribute_id = 1234 - * $query->filterByAttributeId(array(12, 34)); // WHERE attribute_id IN (12, 34) - * $query->filterByAttributeId(array('min' => 12)); // WHERE attribute_id >= 12 - * $query->filterByAttributeId(array('max' => 12)); // WHERE attribute_id <= 12 - * - * - * @see filterByAttribute() - * - * @param mixed $attributeId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeId($attributeId = null, $comparison = null) - { - if (is_array($attributeId)) { - $useMinMax = false; - if (isset($attributeId['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($attributeId['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attributeId, $comparison); - } - - /** - * Filter the query on the combination_id column - * - * Example usage: - * - * $query->filterByCombinationId(1234); // WHERE combination_id = 1234 - * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34) - * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id >= 12 - * $query->filterByCombinationId(array('max' => 12)); // WHERE combination_id <= 12 - * - * - * @see filterByCombination() - * - * @param mixed $combinationId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByCombinationId($combinationId = null, $comparison = null) - { - if (is_array($combinationId)) { - $useMinMax = false; - if (isset($combinationId['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($combinationId['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combinationId, $comparison); - } - - /** - * Filter the query on the attribute_av_id column - * - * Example usage: - * - * $query->filterByAttributeAvId(1234); // WHERE attribute_av_id = 1234 - * $query->filterByAttributeAvId(array(12, 34)); // WHERE attribute_av_id IN (12, 34) - * $query->filterByAttributeAvId(array('min' => 12)); // WHERE attribute_av_id >= 12 - * $query->filterByAttributeAvId(array('max' => 12)); // WHERE attribute_av_id <= 12 - * - * - * @see filterByAttributeAv() - * - * @param mixed $attributeAvId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByAttributeAvId($attributeAvId = null, $comparison = null) - { - if (is_array($attributeAvId)) { - $useMinMax = false; - if (isset($attributeAvId['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($attributeAvId['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAvId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Attribute object - * - * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttribute($attribute, $comparison = null) - { - if ($attribute instanceof Attribute) { - return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Attribute relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function joinAttribute($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Attribute'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Attribute'); - } - - return $this; - } - - /** - * Use the Attribute relation Attribute object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query - */ - public function useAttributeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttribute($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); - } - - /** - * Filter the query by a related AttributeAv object - * - * @param AttributeAv|PropelObjectCollection $attributeAv The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeAv($attributeAv, $comparison = null) - { - if ($attributeAv instanceof AttributeAv) { - return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->getId(), $comparison); - } elseif ($attributeAv instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCombinationPeer::ATTRIBUTE_AV_ID, $attributeAv->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeAv'); - } - - return $this; - } - - /** - * Use the AttributeAv relation AttributeAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query - */ - public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); - } - - /** - * Filter the query by a related Combination object - * - * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeCombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCombination($combination, $comparison = null) - { - if ($combination instanceof Combination) { - return $this - ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->getId(), $comparison); - } elseif ($combination instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeCombinationPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Combination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function joinCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Combination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Combination'); - } - - return $this; - } - - /** - * Use the Combination relation Combination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CombinationQuery A secondary query class using the current class as primary query - */ - public function useCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery'); - } - - /** - * Exclude object from result - * - * @param AttributeCombination $attributeCombination Object to remove from the list of results - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function prune($attributeCombination = null) - { - if ($attributeCombination) { - $this->addCond('pruneCond0', $this->getAliasedColName(AttributeCombinationPeer::ID), $attributeCombination->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(AttributeCombinationPeer::ATTRIBUTE_ID), $attributeCombination->getAttributeId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(AttributeCombinationPeer::COMBINATION_ID), $attributeCombination->getCombinationId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond3', $this->getAliasedColName(AttributeCombinationPeer::ATTRIBUTE_AV_ID), $attributeCombination->getAttributeAvId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2', 'pruneCond3'), Criteria::LOGICAL_OR); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCombinationPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCombinationPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCombinationPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AttributeCombinationPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AttributeCombinationQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AttributeCombinationPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18n.php b/core/lib/Thelia/Model/om/BaseAttributeI18n.php deleted file mode 100755 index acdb567fe..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseAttributeI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AttributeI18nPeer::ID; - } - - if ($this->aAttribute !== null && $this->aAttribute->getId() !== $v) { - $this->aAttribute = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = AttributeI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = AttributeI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = AttributeI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = AttributeI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return AttributeI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = AttributeI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = AttributeI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating AttributeI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aAttribute !== null && $this->id !== $this->aAttribute->getId()) { - $this->aAttribute = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::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 = AttributeI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aAttribute = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = AttributeI18nQuery::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(AttributeI18nPeer::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); - AttributeI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if ($this->aAttribute->isModified() || $this->aAttribute->isNew()) { - $affectedRows += $this->aAttribute->save($con); - } - $this->setAttribute($this->aAttribute); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AttributeI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(AttributeI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(AttributeI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(AttributeI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(AttributeI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(AttributeI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `attribute_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aAttribute !== null) { - if (!$this->aAttribute->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aAttribute->getValidationFailures()); - } - } - - - if (($retval = AttributeI18nPeer::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 = AttributeI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['AttributeI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AttributeI18n'][serialize($this->getPrimaryKey())] = true; - $keys = AttributeI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aAttribute) { - $result['Attribute'] = $this->aAttribute->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = AttributeI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = AttributeI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AttributeI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(AttributeI18nPeer::ID)) $criteria->add(AttributeI18nPeer::ID, $this->id); - if ($this->isColumnModified(AttributeI18nPeer::LOCALE)) $criteria->add(AttributeI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(AttributeI18nPeer::TITLE)) $criteria->add(AttributeI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(AttributeI18nPeer::DESCRIPTION)) $criteria->add(AttributeI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(AttributeI18nPeer::CHAPO)) $criteria->add(AttributeI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(AttributeI18nPeer::POSTSCRIPTUM)) $criteria->add(AttributeI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(AttributeI18nPeer::DATABASE_NAME); - $criteria->add(AttributeI18nPeer::ID, $this->id); - $criteria->add(AttributeI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 AttributeI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 AttributeI18n 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 AttributeI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new AttributeI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Attribute object. - * - * @param Attribute $v - * @return AttributeI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setAttribute(Attribute $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aAttribute = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Attribute object, it will not be re-added. - if ($v !== null) { - $v->addAttributeI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Attribute object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Attribute The associated Attribute object. - * @throws PropelException - */ - public function getAttribute(PropelPDO $con = null, $doQuery = true) - { - if ($this->aAttribute === null && ($this->id !== null) && $doQuery) { - $this->aAttribute = AttributeQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAttribute->addAttributeI18ns($this); - */ - } - - return $this->aAttribute; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aAttribute instanceof Persistent) { - $this->aAttribute->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aAttribute = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AttributeI18nPeer::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/BaseAttributeI18nPeer.php b/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php deleted file mode 100755 index a26444434..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (AttributeI18nPeer::ID, AttributeI18nPeer::LOCALE, AttributeI18nPeer::TITLE, AttributeI18nPeer::DESCRIPTION, AttributeI18nPeer::CHAPO, AttributeI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributeI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (AttributeI18nPeer::ID => 0, AttributeI18nPeer::LOCALE => 1, AttributeI18nPeer::TITLE => 2, AttributeI18nPeer::DESCRIPTION => 3, AttributeI18nPeer::CHAPO => 4, AttributeI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributeI18nPeer::getFieldNames($toType); - $key = isset(AttributeI18nPeer::$fieldKeys[$fromType][$name]) ? AttributeI18nPeer::$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(AttributeI18nPeer::$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, AttributeI18nPeer::$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 AttributeI18nPeer::$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. AttributeI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributeI18nPeer::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(AttributeI18nPeer::ID); - $criteria->addSelectColumn(AttributeI18nPeer::LOCALE); - $criteria->addSelectColumn(AttributeI18nPeer::TITLE); - $criteria->addSelectColumn(AttributeI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(AttributeI18nPeer::CHAPO); - $criteria->addSelectColumn(AttributeI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(AttributeI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributeI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::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 AttributeI18n - * @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 = AttributeI18nPeer::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 AttributeI18nPeer::populateObjects(AttributeI18nPeer::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 directly (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(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributeI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributeI18nPeer::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 AttributeI18n $obj A AttributeI18n 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->getLocale())); - } // if key === null - AttributeI18nPeer::$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 AttributeI18n 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 AttributeI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 AttributeI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributeI18nPeer::$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 AttributeI18n 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(AttributeI18nPeer::$instances[$key])) { - return AttributeI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributeI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributeI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributeI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributeI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributeI18nPeer::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; - AttributeI18nPeer::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 (AttributeI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributeI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributeI18nPeer::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 + AttributeI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributeI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributeI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Attribute table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAttribute(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributeI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeI18nPeer::ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of AttributeI18n objects pre-filled with their Attribute objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of AttributeI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAttribute(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(AttributeI18nPeer::DATABASE_NAME); - } - - AttributeI18nPeer::addSelectColumns($criteria); - $startcol = AttributeI18nPeer::NUM_HYDRATE_COLUMNS; - AttributePeer::addSelectColumns($criteria); - - $criteria->addJoin(AttributeI18nPeer::ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = AttributeI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (AttributeI18n) to $obj2 (Attribute) - $obj2->addAttributeI18n($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(AttributeI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributeI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(AttributeI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(AttributeI18nPeer::ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of AttributeI18n 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 AttributeI18n 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(AttributeI18nPeer::DATABASE_NAME); - } - - AttributeI18nPeer::addSelectColumns($criteria); - $startcol2 = AttributeI18nPeer::NUM_HYDRATE_COLUMNS; - - AttributePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AttributePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(AttributeI18nPeer::ID, AttributePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = AttributeI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = AttributeI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = AttributeI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - AttributeI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Attribute rows - - $key2 = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AttributePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AttributePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AttributePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (AttributeI18n) to the collection in $obj2 (Attribute) - $obj2->addAttributeI18n($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(AttributeI18nPeer::DATABASE_NAME)->getTable(AttributeI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributeI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributeI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributeI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a AttributeI18n or Criteria object. - * - * @param mixed $values Criteria or AttributeI18n 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(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from AttributeI18n object - } - - - // Set the correct dbName - $criteria->setDbName(AttributeI18nPeer::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 AttributeI18n or Criteria object. - * - * @param mixed $values Criteria or AttributeI18n 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(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributeI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributeI18nPeer::ID); - $value = $criteria->remove(AttributeI18nPeer::ID); - if ($value) { - $selectCriteria->add(AttributeI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(AttributeI18nPeer::LOCALE); - $value = $criteria->remove(AttributeI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(AttributeI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributeI18nPeer::TABLE_NAME); - } - - } else { // $values is AttributeI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributeI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute_i18n 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(AttributeI18nPeer::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(AttributeI18nPeer::TABLE_NAME, $con, AttributeI18nPeer::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). - AttributeI18nPeer::clearInstancePool(); - AttributeI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a AttributeI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AttributeI18n 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(AttributeI18nPeer::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. - AttributeI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof AttributeI18n) { // it's a model object - // invalidate the cache for this single object - AttributeI18nPeer::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(AttributeI18nPeer::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(AttributeI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(AttributeI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - AttributeI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributeI18nPeer::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); - AttributeI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given AttributeI18n 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 AttributeI18n $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(AttributeI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributeI18nPeer::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(AttributeI18nPeer::DATABASE_NAME, AttributeI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return AttributeI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = AttributeI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributeI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(AttributeI18nPeer::DATABASE_NAME); - $criteria->add(AttributeI18nPeer::ID, $id); - $criteria->add(AttributeI18nPeer::LOCALE, $locale); - $v = AttributeI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseAttributeI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributeI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php b/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php deleted file mode 100755 index f21a25d3a..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return AttributeI18n|AttributeI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributeI18nPeer::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(AttributeI18nPeer::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 AttributeI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `attribute_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 AttributeI18n(); - $obj->hydrate($row); - AttributeI18nPeer::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 AttributeI18n|AttributeI18n[]|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|AttributeI18n[]|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 AttributeI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(AttributeI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(AttributeI18nPeer::LOCALE, $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 AttributeI18nQuery 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(AttributeI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(AttributeI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByAttribute() - * - * @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 AttributeI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributeI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributeI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 AttributeI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(AttributeI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Attribute object - * - * @param Attribute|PropelObjectCollection $attribute The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttribute($attribute, $comparison = null) - { - if ($attribute instanceof Attribute) { - return $this - ->addUsingAlias(AttributeI18nPeer::ID, $attribute->getId(), $comparison); - } elseif ($attribute instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AttributeI18nPeer::ID, $attribute->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAttribute() only accepts arguments of type Attribute or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Attribute relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function joinAttribute($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Attribute'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Attribute'); - } - - return $this; - } - - /** - * Use the Attribute relation Attribute object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeQuery A secondary query class using the current class as primary query - */ - public function useAttributeQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinAttribute($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Attribute', '\Thelia\Model\AttributeQuery'); - } - - /** - * Exclude object from result - * - * @param AttributeI18n $attributeI18n Object to remove from the list of results - * - * @return AttributeI18nQuery The current query, for fluid interface - */ - public function prune($attributeI18n = null) - { - if ($attributeI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(AttributeI18nPeer::ID), $attributeI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(AttributeI18nPeer::LOCALE), $attributeI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseAttributePeer.php b/core/lib/Thelia/Model/om/BaseAttributePeer.php deleted file mode 100755 index 47f649d15..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributePeer.php +++ /dev/null @@ -1,808 +0,0 @@ - array ('Id', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (AttributePeer::ID, AttributePeer::POSITION, AttributePeer::CREATED_AT, AttributePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. AttributePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Position' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'position' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (AttributePeer::ID => 0, AttributePeer::POSITION => 1, AttributePeer::CREATED_AT => 2, AttributePeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'POSITION' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'position' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = AttributePeer::getFieldNames($toType); - $key = isset(AttributePeer::$fieldKeys[$fromType][$name]) ? AttributePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(AttributePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, AttributePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return AttributePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. AttributePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(AttributePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AttributePeer::ID); - $criteria->addSelectColumn(AttributePeer::POSITION); - $criteria->addSelectColumn(AttributePeer::CREATED_AT); - $criteria->addSelectColumn(AttributePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(AttributePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - AttributePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(AttributePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Attribute - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = AttributePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return AttributePeer::populateObjects(AttributePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - AttributePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(AttributePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Attribute $obj A Attribute object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - AttributePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Attribute object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Attribute) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Attribute object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(AttributePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Attribute Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(AttributePeer::$instances[$key])) { - return AttributePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (AttributePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - AttributePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to attribute - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AttributeAvPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeAvPeer::clearInstancePool(); - // Invalidate objects in AttributeCombinationPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCombinationPeer::clearInstancePool(); - // Invalidate objects in AttributeCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCategoryPeer::clearInstancePool(); - // Invalidate objects in AttributeI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = AttributePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = AttributePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = AttributePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AttributePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Attribute object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = AttributePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = AttributePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + AttributePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = AttributePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - AttributePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(AttributePeer::DATABASE_NAME)->getTable(AttributePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseAttributePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseAttributePeer::TABLE_NAME)) { - $dbMap->addTableObject(new AttributeTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return AttributePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Attribute or Criteria object. - * - * @param mixed $values Criteria or Attribute object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Attribute object - } - - if ($criteria->containsKey(AttributePeer::ID) && $criteria->keyContainsValue(AttributePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AttributePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(AttributePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Attribute or Criteria object. - * - * @param mixed $values Criteria or Attribute object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(AttributePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(AttributePeer::ID); - $value = $criteria->remove(AttributePeer::ID); - if ($value) { - $selectCriteria->add(AttributePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(AttributePeer::TABLE_NAME); - } - - } else { // $values is Attribute object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(AttributePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the attribute table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(AttributePeer::TABLE_NAME, $con, AttributePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AttributePeer::clearInstancePool(); - AttributePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Attribute or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Attribute object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - AttributePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Attribute) { // it's a model object - // invalidate the cache for this single object - AttributePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - $criteria->add(AttributePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - AttributePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(AttributePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - AttributePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Attribute object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Attribute $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(AttributePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(AttributePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(AttributePeer::DATABASE_NAME, AttributePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Attribute - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = AttributePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - $criteria->add(AttributePeer::ID, $pk); - - $v = AttributePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Attribute[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(AttributePeer::DATABASE_NAME); - $criteria->add(AttributePeer::ID, $pks, Criteria::IN); - $objs = AttributePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseAttributePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseAttributePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseAttributeQuery.php b/core/lib/Thelia/Model/om/BaseAttributeQuery.php deleted file mode 100755 index 50ffbe964..000000000 --- a/core/lib/Thelia/Model/om/BaseAttributeQuery.php +++ /dev/null @@ -1,883 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AttributePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(AttributePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Attribute A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Attribute A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `position`, `created_at`, `updated_at` FROM `attribute` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Attribute(); - $obj->hydrate($row); - AttributePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Attribute|Attribute[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Attribute[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(AttributePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(AttributePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AttributePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AttributePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributePeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(AttributePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(AttributePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributePeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related AttributeAv object - * - * @param AttributeAv|PropelObjectCollection $attributeAv the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeAv($attributeAv, $comparison = null) - { - if ($attributeAv instanceof AttributeAv) { - return $this - ->addUsingAlias(AttributePeer::ID, $attributeAv->getAttributeId(), $comparison); - } elseif ($attributeAv instanceof PropelObjectCollection) { - return $this - ->useAttributeAvQuery() - ->filterByPrimaryKeys($attributeAv->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeAv() only accepts arguments of type AttributeAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinAttributeAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeAv'); - } - - return $this; - } - - /** - * Use the AttributeAv relation AttributeAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeAvQuery A secondary query class using the current class as primary query - */ - public function useAttributeAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeAv', '\Thelia\Model\AttributeAvQuery'); - } - - /** - * Filter the query by a related AttributeCombination object - * - * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeCombination($attributeCombination, $comparison = null) - { - if ($attributeCombination instanceof AttributeCombination) { - return $this - ->addUsingAlias(AttributePeer::ID, $attributeCombination->getAttributeId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { - return $this - ->useAttributeCombinationQuery() - ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCombination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCombination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCombination'); - } - - return $this; - } - - /** - * Use the AttributeCombination relation AttributeCombination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query - */ - public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery'); - } - - /** - * Filter the query by a related AttributeCategory object - * - * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) - { - if ($attributeCategory instanceof AttributeCategory) { - return $this - ->addUsingAlias(AttributePeer::ID, $attributeCategory->getAttributeId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { - return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCategory'); - } - - return $this; - } - - /** - * Use the AttributeCategory relation AttributeCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query - */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); - } - - /** - * Filter the query by a related AttributeI18n object - * - * @param AttributeI18n|PropelObjectCollection $attributeI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeI18n($attributeI18n, $comparison = null) - { - if ($attributeI18n instanceof AttributeI18n) { - return $this - ->addUsingAlias(AttributePeer::ID, $attributeI18n->getId(), $comparison); - } elseif ($attributeI18n instanceof PropelObjectCollection) { - return $this - ->useAttributeI18nQuery() - ->filterByPrimaryKeys($attributeI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeI18n() only accepts arguments of type AttributeI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinAttributeI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeI18n'); - } - - return $this; - } - - /** - * Use the AttributeI18n relation AttributeI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeI18nQuery A secondary query class using the current class as primary query - */ - public function useAttributeI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinAttributeI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', '\Thelia\Model\AttributeI18nQuery'); - } - - /** - * Filter the query by a related Category object - * using the attribute_category table as cross reference - * - * @param Category $category the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return AttributeQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = Criteria::EQUAL) - { - return $this - ->useAttributeCategoryQuery() - ->filterByCategory($category, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Attribute $attribute Object to remove from the list of results - * - * @return AttributeQuery The current query, for fluid interface - */ - public function prune($attribute = null) - { - if ($attribute) { - $this->addUsingAlias(AttributePeer::ID, $attribute->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return AttributeQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AttributePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return AttributeQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AttributePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return AttributeQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AttributePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return AttributeQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AttributePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return AttributeQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AttributePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return AttributeQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AttributePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; - - return $this - ->joinAttributeI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('AttributeI18n'); - $this->with['AttributeI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return AttributeI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeI18n', 'Thelia\Model\AttributeI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCategory.php b/core/lib/Thelia/Model/om/BaseCategory.php deleted file mode 100755 index f28b3b513..000000000 --- a/core/lib/Thelia/Model/om/BaseCategory.php +++ /dev/null @@ -1,5534 +0,0 @@ -version = 0; - } - - /** - * Initializes internal state of BaseCategory 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 Category The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CategoryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [parent] column. - * - * @param int $v new value - * @return Category The current object (for fluent API support) - */ - public function setParent($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->parent !== $v) { - $this->parent = $v; - $this->modifiedColumns[] = CategoryPeer::PARENT; - } - - - return $this; - } // setParent() - - /** - * Set the value of [link] column. - * - * @param string $v new value - * @return Category The current object (for fluent API support) - */ - public function setLink($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->link !== $v) { - $this->link = $v; - $this->modifiedColumns[] = CategoryPeer::LINK; - } - - - return $this; - } // setLink() - - /** - * Set the value of [visible] column. - * - * @param int $v new value - * @return Category The current object (for fluent API support) - */ - public function setVisible($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->visible !== $v) { - $this->visible = $v; - $this->modifiedColumns[] = CategoryPeer::VISIBLE; - } - - - return $this; - } // setVisible() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Category The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = CategoryPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Category The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CategoryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Category The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CategoryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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. - * - * 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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = CategoryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Category object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collProductCategorys = null; - - $this->collFeatureCategorys = null; - - $this->collAttributeCategorys = null; - - $this->collContentAssocs = null; - - $this->collImages = null; - - $this->collDocuments = null; - - $this->collRewritings = null; - - $this->collCategoryI18ns = null; - - $this->collCategoryVersions = null; - - $this->collProducts = null; - $this->collFeatures = null; - $this->collAttributes = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CategoryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - // 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 - if (!$this->isColumnModified(CategoryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - // versionable behavior - if (isset($createVersion)) { - $this->addVersion($con); - } - CategoryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->productsScheduledForDeletion !== null) { - if (!$this->productsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->productsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - ProductCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->productsScheduledForDeletion = null; - } - - foreach ($this->getProducts() as $product) { - if ($product->isModified()) { - $product->save($con); - } - } - } elseif ($this->collProducts) { - foreach ($this->collProducts as $product) { - if ($product->isModified()) { - $product->save($con); - } - } - } - - if ($this->featuresScheduledForDeletion !== null) { - if (!$this->featuresScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->featuresScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->featuresScheduledForDeletion = null; - } - - foreach ($this->getFeatures() as $feature) { - if ($feature->isModified()) { - $feature->save($con); - } - } - } elseif ($this->collFeatures) { - foreach ($this->collFeatures as $feature) { - if ($feature->isModified()) { - $feature->save($con); - } - } - } - - if ($this->attributesScheduledForDeletion !== null) { - if (!$this->attributesScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->attributesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->attributesScheduledForDeletion = null; - } - - foreach ($this->getAttributes() as $attribute) { - if ($attribute->isModified()) { - $attribute->save($con); - } - } - } elseif ($this->collAttributes) { - foreach ($this->collAttributes as $attribute) { - if ($attribute->isModified()) { - $attribute->save($con); - } - } - } - - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productCategorysScheduledForDeletion = null; - } - } - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureCategorysScheduledForDeletion !== null) { - if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureCategorysScheduledForDeletion = null; - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->attributeCategorysScheduledForDeletion !== null) { - if (!$this->attributeCategorysScheduledForDeletion->isEmpty()) { - AttributeCategoryQuery::create() - ->filterByPrimaryKeys($this->attributeCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCategorysScheduledForDeletion = null; - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - foreach ($this->imagesScheduledForDeletion as $image) { - // need to save related object because we set the relation to null - $image->save($con); - } - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - foreach ($this->rewritingsScheduledForDeletion as $rewriting) { - // need to save related object because we set the relation to null - $rewriting->save($con); - } - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->categoryI18nsScheduledForDeletion !== null) { - if (!$this->categoryI18nsScheduledForDeletion->isEmpty()) { - CategoryI18nQuery::create() - ->filterByPrimaryKeys($this->categoryI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->categoryI18nsScheduledForDeletion = null; - } - } - - if ($this->collCategoryI18ns !== null) { - foreach ($this->collCategoryI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - 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() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CategoryPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CategoryPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CategoryPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; - } - if ($this->isColumnModified(CategoryPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`link`'; - } - if ($this->isColumnModified(CategoryPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; - } - if ($this->isColumnModified(CategoryPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(CategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - 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)', - 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); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CategoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAttributeCategorys !== null) { - foreach ($this->collAttributeCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCategoryI18ns !== null) { - foreach ($this->collCategoryI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCategoryVersions !== null) { - foreach ($this->collCategoryVersions as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getParent(); - break; - case 2: - return $this->getLink(); - break; - case 3: - return $this->getVisible(); - break; - case 4: - return $this->getPosition(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - 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['Category'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Category'][$this->getPrimaryKey()] = true; - $keys = CategoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getParent(), - $keys[2] => $this->getLink(), - $keys[3] => $this->getVisible(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), - ); - if ($includeForeignObjects) { - if (null !== $this->collProductCategorys) { - $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureCategorys) { - $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAttributeCategorys) { - $result['AttributeCategorys'] = $this->collAttributeCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->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; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setParent($value); - break; - case 2: - $this->setLink($value); - break; - case 3: - $this->setVisible($value); - break; - case 4: - $this->setPosition($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - 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 = CategoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - 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(CategoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(CategoryPeer::ID)) $criteria->add(CategoryPeer::ID, $this->id); - if ($this->isColumnModified(CategoryPeer::PARENT)) $criteria->add(CategoryPeer::PARENT, $this->parent); - if ($this->isColumnModified(CategoryPeer::LINK)) $criteria->add(CategoryPeer::LINK, $this->link); - if ($this->isColumnModified(CategoryPeer::VISIBLE)) $criteria->add(CategoryPeer::VISIBLE, $this->visible); - if ($this->isColumnModified(CategoryPeer::POSITION)) $criteria->add(CategoryPeer::POSITION, $this->position); - if ($this->isColumnModified(CategoryPeer::CREATED_AT)) $criteria->add(CategoryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CategoryPeer::UPDATED_AT)) $criteria->add(CategoryPeer::UPDATED_AT, $this->updated_at); - 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; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); - $criteria->add(CategoryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Category (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setParent($this->getParent()); - $copyObj->setLink($this->getLink()); - $copyObj->setVisible($this->getVisible()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - $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; - - foreach ($this->getProductCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAttributeCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCategoryI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCategoryI18n($relObj->copy($deepCopy)); - } - } - - 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) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Category Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CategoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CategoryPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('ProductCategory' == $relationName) { - $this->initProductCategorys(); - } - if ('FeatureCategory' == $relationName) { - $this->initFeatureCategorys(); - } - if ('AttributeCategory' == $relationName) { - $this->initAttributeCategorys(); - } - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } - if ('Image' == $relationName) { - $this->initImages(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('Rewriting' == $relationName) { - $this->initRewritings(); - } - if ('CategoryI18n' == $relationName) { - $this->initCategoryI18ns(); - } - if ('CategoryVersion' == $relationName) { - $this->initCategoryVersions(); - } - } - - /** - * Clears out the collProductCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addProductCategorys() - */ - public function clearProductCategorys() - { - $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized - $this->collProductCategorysPartial = null; - - return $this; - } - - /** - * reset is the collProductCategorys collection loaded partially - * - * @return void - */ - public function resetPartialProductCategorys($v = true) - { - $this->collProductCategorysPartial = $v; - } - - /** - * Initializes the collProductCategorys collection. - * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initProductCategorys($overrideExisting = true) - { - if (null !== $this->collProductCategorys && !$overrideExisting) { - return; - } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); - } - - /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - * @throws PropelException - */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { - // return empty collection - $this->initProductCategorys(); - } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); - - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); - } - } - - $this->collProductCategorysPartial = true; - } - - $collProductCategorys->getInternalIterator()->rewind(); - return $collProductCategorys; - } - - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { - if($obj->isNew()) { - $collProductCategorys[] = $obj; - } - } - } - - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; - } - } - - return $this->collProductCategorys; - } - - /** - * Sets a collection of ProductCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $productCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) - { - $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); - - $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); - - foreach ($productCategorysToDelete as $productCategoryRemoved) { - $productCategoryRemoved->setCategory(null); - } - - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { - $this->addProductCategory($productCategory); - } - - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related ProductCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ProductCategory objects. - * @throws PropelException - */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getProductCategorys()); - } - $query = ProductCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collProductCategorys); - } - - /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. - * - * @param ProductCategory $l ProductCategory - * @return Category The current object (for fluent API support) - */ - public function addProductCategory(ProductCategory $l) - { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; - } - if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddProductCategory($l); - } - - return $this; - } - - /** - * @param ProductCategory $productCategory The productCategory object to add. - */ - protected function doAddProductCategory($productCategory) - { - $this->collProductCategorys[]= $productCategory; - $productCategory->setCategory($this); - } - - /** - * @param ProductCategory $productCategory The productCategory object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeProductCategory($productCategory) - { - if ($this->getProductCategorys()->contains($productCategory)) { - $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); - if (null === $this->productCategorysScheduledForDeletion) { - $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; - $this->productCategorysScheduledForDeletion->clear(); - } - $this->productCategorysScheduledForDeletion[]= clone $productCategory; - $productCategory->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ProductCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - */ - public function getProductCategorysJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ProductCategoryQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getProductCategorys($query, $con); - } - - /** - * Clears out the collFeatureCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addFeatureCategorys() - */ - public function clearFeatureCategorys() - { - $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized - $this->collFeatureCategorysPartial = null; - - return $this; - } - - /** - * reset is the collFeatureCategorys collection loaded partially - * - * @return void - */ - public function resetPartialFeatureCategorys($v = true) - { - $this->collFeatureCategorysPartial = $v; - } - - /** - * Initializes the collFeatureCategorys collection. - * - * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureCategorys($overrideExisting = true) - { - if (null !== $this->collFeatureCategorys && !$overrideExisting) { - return; - } - $this->collFeatureCategorys = new PropelObjectCollection(); - $this->collFeatureCategorys->setModel('FeatureCategory'); - } - - /** - * Gets an array of FeatureCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - * @throws PropelException - */ - public function getFeatureCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { - // return empty collection - $this->initFeatureCategorys(); - } else { - $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { - $this->initFeatureCategorys(false); - - foreach($collFeatureCategorys as $obj) { - if (false == $this->collFeatureCategorys->contains($obj)) { - $this->collFeatureCategorys->append($obj); - } - } - - $this->collFeatureCategorysPartial = true; - } - - $collFeatureCategorys->getInternalIterator()->rewind(); - return $collFeatureCategorys; - } - - if($partial && $this->collFeatureCategorys) { - foreach($this->collFeatureCategorys as $obj) { - if($obj->isNew()) { - $collFeatureCategorys[] = $obj; - } - } - } - - $this->collFeatureCategorys = $collFeatureCategorys; - $this->collFeatureCategorysPartial = false; - } - } - - return $this->collFeatureCategorys; - } - - /** - * Sets a collection of FeatureCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) - { - $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); - - $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); - - foreach ($featureCategorysToDelete as $featureCategoryRemoved) { - $featureCategoryRemoved->setCategory(null); - } - - $this->collFeatureCategorys = null; - foreach ($featureCategorys as $featureCategory) { - $this->addFeatureCategory($featureCategory); - } - - $this->collFeatureCategorys = $featureCategorys; - $this->collFeatureCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureCategory objects. - * @throws PropelException - */ - public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); - } - $query = FeatureCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collFeatureCategorys); - } - - /** - * Method called to associate a FeatureCategory object to this object - * through the FeatureCategory foreign key attribute. - * - * @param FeatureCategory $l FeatureCategory - * @return Category The current object (for fluent API support) - */ - public function addFeatureCategory(FeatureCategory $l) - { - if ($this->collFeatureCategorys === null) { - $this->initFeatureCategorys(); - $this->collFeatureCategorysPartial = true; - } - if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureCategory($l); - } - - return $this; - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to add. - */ - protected function doAddFeatureCategory($featureCategory) - { - $this->collFeatureCategorys[]= $featureCategory; - $featureCategory->setCategory($this); - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeFeatureCategory($featureCategory) - { - if ($this->getFeatureCategorys()->contains($featureCategory)) { - $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory)); - if (null === $this->featureCategorysScheduledForDeletion) { - $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; - $this->featureCategorysScheduledForDeletion->clear(); - } - $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; - $featureCategory->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related FeatureCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - */ - public function getFeatureCategorysJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); - - return $this->getFeatureCategorys($query, $con); - } - - /** - * Clears out the collAttributeCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addAttributeCategorys() - */ - public function clearAttributeCategorys() - { - $this->collAttributeCategorys = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCategorysPartial = null; - - return $this; - } - - /** - * reset is the collAttributeCategorys collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCategorys($v = true) - { - $this->collAttributeCategorysPartial = $v; - } - - /** - * Initializes the collAttributeCategorys collection. - * - * By default this just sets the collAttributeCategorys collection to an empty array (like clearcollAttributeCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCategorys($overrideExisting = true) - { - if (null !== $this->collAttributeCategorys && !$overrideExisting) { - return; - } - $this->collAttributeCategorys = new PropelObjectCollection(); - $this->collAttributeCategorys->setModel('AttributeCategory'); - } - - /** - * Gets an array of AttributeCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - * @throws PropelException - */ - public function getAttributeCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { - // return empty collection - $this->initAttributeCategorys(); - } else { - $collAttributeCategorys = AttributeCategoryQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCategorysPartial && count($collAttributeCategorys)) { - $this->initAttributeCategorys(false); - - foreach($collAttributeCategorys as $obj) { - if (false == $this->collAttributeCategorys->contains($obj)) { - $this->collAttributeCategorys->append($obj); - } - } - - $this->collAttributeCategorysPartial = true; - } - - $collAttributeCategorys->getInternalIterator()->rewind(); - return $collAttributeCategorys; - } - - if($partial && $this->collAttributeCategorys) { - foreach($this->collAttributeCategorys as $obj) { - if($obj->isNew()) { - $collAttributeCategorys[] = $obj; - } - } - } - - $this->collAttributeCategorys = $collAttributeCategorys; - $this->collAttributeCategorysPartial = false; - } - } - - return $this->collAttributeCategorys; - } - - /** - * Sets a collection of AttributeCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setAttributeCategorys(PropelCollection $attributeCategorys, PropelPDO $con = null) - { - $attributeCategorysToDelete = $this->getAttributeCategorys(new Criteria(), $con)->diff($attributeCategorys); - - $this->attributeCategorysScheduledForDeletion = unserialize(serialize($attributeCategorysToDelete)); - - foreach ($attributeCategorysToDelete as $attributeCategoryRemoved) { - $attributeCategoryRemoved->setCategory(null); - } - - $this->collAttributeCategorys = null; - foreach ($attributeCategorys as $attributeCategory) { - $this->addAttributeCategory($attributeCategory); - } - - $this->collAttributeCategorys = $attributeCategorys; - $this->collAttributeCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCategory objects. - * @throws PropelException - */ - public function countAttributeCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCategorysPartial && !$this->isNew(); - if (null === $this->collAttributeCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeCategorys()); - } - $query = AttributeCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collAttributeCategorys); - } - - /** - * Method called to associate a AttributeCategory object to this object - * through the AttributeCategory foreign key attribute. - * - * @param AttributeCategory $l AttributeCategory - * @return Category The current object (for fluent API support) - */ - public function addAttributeCategory(AttributeCategory $l) - { - if ($this->collAttributeCategorys === null) { - $this->initAttributeCategorys(); - $this->collAttributeCategorysPartial = true; - } - if (!in_array($l, $this->collAttributeCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCategory($l); - } - - return $this; - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to add. - */ - protected function doAddAttributeCategory($attributeCategory) - { - $this->collAttributeCategorys[]= $attributeCategory; - $attributeCategory->setCategory($this); - } - - /** - * @param AttributeCategory $attributeCategory The attributeCategory object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeAttributeCategory($attributeCategory) - { - if ($this->getAttributeCategorys()->contains($attributeCategory)) { - $this->collAttributeCategorys->remove($this->collAttributeCategorys->search($attributeCategory)); - if (null === $this->attributeCategorysScheduledForDeletion) { - $this->attributeCategorysScheduledForDeletion = clone $this->collAttributeCategorys; - $this->attributeCategorysScheduledForDeletion->clear(); - } - $this->attributeCategorysScheduledForDeletion[]= clone $attributeCategory; - $attributeCategory->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related AttributeCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCategory[] List of AttributeCategory objects - */ - public function getAttributeCategorysJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCategoryQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); - - return $this->getAttributeCategorys($query, $con); - } - - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; - } - - /** - * reset is the collContentAssocs collection loaded partially - * - * @return void - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); - } - - /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - return $collContentAssocs; - } - - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentAssocs A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setCategory(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. - * - * @param ContentAssoc $l ContentAssoc - * @return Category The current object (for fluent API support) - */ - public function addContentAssoc(ContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setCategory($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; - } - - /** - * reset is the collImages collection loaded partially - * - * @return void - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); - } - - /** - * Gets an array of Image objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Image[] List of Image objects - * @throws PropelException - */ - public function getImages($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ImageQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - return $collImages; - } - - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $images A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setImages(PropelCollection $images, PropelPDO $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setCategory(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. - * - * @param Image $l Image - * @return Category The current object (for fluent API support) - */ - public function addImage(Image $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setCategory($this); - } - - /** - * @param Image $image The image object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setCategory(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Category The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setCategory($this); - } - - /** - * @param Document $document The document object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; - } - - /** - * reset is the collRewritings collection loaded partially - * - * @return void - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); - } - - /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Category is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = RewritingQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - return $collRewritings; - } - - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $rewritings A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setCategory(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. - * - * @param Rewriting $l Rewriting - * @return Category The current object (for fluent API support) - */ - public function addRewriting(Rewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setCategory($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setCategory(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Category is new, it will return - * an empty collection; or if this Category has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Category. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getRewritings($query, $con); - } - - /** - * Clears out the collCategoryI18ns 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 Category The current object (for fluent API support) - * @see addCategoryI18ns() - */ - public function clearCategoryI18ns() - { - $this->collCategoryI18ns = null; // important to set this to null since that means it is uninitialized - $this->collCategoryI18nsPartial = null; - - return $this; - } - - /** - * reset is the collCategoryI18ns collection loaded partially - * - * @return void - */ - public function resetPartialCategoryI18ns($v = true) - { - $this->collCategoryI18nsPartial = $v; - } - - /** - * Initializes the collCategoryI18ns collection. - * - * By default this just sets the collCategoryI18ns collection to an empty array (like clearcollCategoryI18ns()); - * 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 initCategoryI18ns($overrideExisting = true) - { - if (null !== $this->collCategoryI18ns && !$overrideExisting) { - return; - } - $this->collCategoryI18ns = new PropelObjectCollection(); - $this->collCategoryI18ns->setModel('CategoryI18n'); - } - - /** - * Gets an array of CategoryI18n 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|CategoryI18n[] List of CategoryI18n objects - * @throws PropelException - */ - public function getCategoryI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCategoryI18nsPartial && !$this->isNew(); - if (null === $this->collCategoryI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCategoryI18ns) { - // return empty collection - $this->initCategoryI18ns(); - } else { - $collCategoryI18ns = CategoryI18nQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCategoryI18nsPartial && count($collCategoryI18ns)) { - $this->initCategoryI18ns(false); - - foreach($collCategoryI18ns as $obj) { - if (false == $this->collCategoryI18ns->contains($obj)) { - $this->collCategoryI18ns->append($obj); - } - } - - $this->collCategoryI18nsPartial = true; - } - - $collCategoryI18ns->getInternalIterator()->rewind(); - return $collCategoryI18ns; - } - - if($partial && $this->collCategoryI18ns) { - foreach($this->collCategoryI18ns as $obj) { - if($obj->isNew()) { - $collCategoryI18ns[] = $obj; - } - } - } - - $this->collCategoryI18ns = $collCategoryI18ns; - $this->collCategoryI18nsPartial = false; - } - } - - return $this->collCategoryI18ns; - } - - /** - * Sets a collection of CategoryI18n 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 $categoryI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setCategoryI18ns(PropelCollection $categoryI18ns, PropelPDO $con = null) - { - $categoryI18nsToDelete = $this->getCategoryI18ns(new Criteria(), $con)->diff($categoryI18ns); - - $this->categoryI18nsScheduledForDeletion = unserialize(serialize($categoryI18nsToDelete)); - - foreach ($categoryI18nsToDelete as $categoryI18nRemoved) { - $categoryI18nRemoved->setCategory(null); - } - - $this->collCategoryI18ns = null; - foreach ($categoryI18ns as $categoryI18n) { - $this->addCategoryI18n($categoryI18n); - } - - $this->collCategoryI18ns = $categoryI18ns; - $this->collCategoryI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related CategoryI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CategoryI18n objects. - * @throws PropelException - */ - public function countCategoryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCategoryI18nsPartial && !$this->isNew(); - if (null === $this->collCategoryI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCategoryI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCategoryI18ns()); - } - $query = CategoryI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collCategoryI18ns); - } - - /** - * Method called to associate a CategoryI18n object to this object - * through the CategoryI18n foreign key attribute. - * - * @param CategoryI18n $l CategoryI18n - * @return Category The current object (for fluent API support) - */ - public function addCategoryI18n(CategoryI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collCategoryI18ns === null) { - $this->initCategoryI18ns(); - $this->collCategoryI18nsPartial = true; - } - if (!in_array($l, $this->collCategoryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCategoryI18n($l); - } - - return $this; - } - - /** - * @param CategoryI18n $categoryI18n The categoryI18n object to add. - */ - protected function doAddCategoryI18n($categoryI18n) - { - $this->collCategoryI18ns[]= $categoryI18n; - $categoryI18n->setCategory($this); - } - - /** - * @param CategoryI18n $categoryI18n The categoryI18n object to remove. - * @return Category The current object (for fluent API support) - */ - public function removeCategoryI18n($categoryI18n) - { - if ($this->getCategoryI18ns()->contains($categoryI18n)) { - $this->collCategoryI18ns->remove($this->collCategoryI18ns->search($categoryI18n)); - if (null === $this->categoryI18nsScheduledForDeletion) { - $this->categoryI18nsScheduledForDeletion = clone $this->collCategoryI18ns; - $this->categoryI18nsScheduledForDeletion->clear(); - } - $this->categoryI18nsScheduledForDeletion[]= clone $categoryI18n; - $categoryI18n->setCategory(null); - } - - return $this; - } - - /** - * 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 Category The current object (for fluent API support) - * @see addCategoryVersions() - */ - public function clearCategoryVersions() - { - $this->collCategoryVersions = null; // important to set this to null since that means it is uninitialized - $this->collCategoryVersionsPartial = null; - - return $this; - } - - /** - * 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; - } - - $collCategoryVersions->getInternalIterator()->rewind(); - 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 - * @return Category The current object (for fluent API support) - */ - public function setCategoryVersions(PropelCollection $categoryVersions, PropelPDO $con = null) - { - $categoryVersionsToDelete = $this->getCategoryVersions(new Criteria(), $con)->diff($categoryVersions); - - $this->categoryVersionsScheduledForDeletion = unserialize(serialize($categoryVersionsToDelete)); - - foreach ($categoryVersionsToDelete as $categoryVersionRemoved) { - $categoryVersionRemoved->setCategory(null); - } - - $this->collCategoryVersions = null; - foreach ($categoryVersions as $categoryVersion) { - $this->addCategoryVersion($categoryVersion); - } - - $this->collCategoryVersions = $categoryVersions; - $this->collCategoryVersionsPartial = false; - - return $this; - } - - /** - * 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; - } - - if($partial && !$criteria) { - return count($this->getCategoryVersions()); - } - $query = CategoryVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - - return count($this->collCategoryVersions); - } - - /** - * 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 (!in_array($l, $this->collCategoryVersions->getArrayCopy(), true)) { // 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. - * @return Category The current object (for fluent API support) - */ - 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[]= clone $categoryVersion; - $categoryVersion->setCategory(null); - } - - return $this; - } - - /** - * Clears out the collProducts collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Category The current object (for fluent API support) - * @see addProducts() - */ - public function clearProducts() - { - $this->collProducts = null; // important to set this to null since that means it is uninitialized - $this->collProductsPartial = null; - - return $this; - } - - /** - * Initializes the collProducts collection. - * - * By default this just sets the collProducts collection to an empty collection (like clearProducts()); - * 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. - * - * @return void - */ - public function initProducts() - { - $this->collProducts = new PropelObjectCollection(); - $this->collProducts->setModel('Product'); - } - - /** - * Gets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Product[] List of Product objects - */ - public function getProducts($criteria = null, PropelPDO $con = null) - { - if (null === $this->collProducts || null !== $criteria) { - if ($this->isNew() && null === $this->collProducts) { - // return empty collection - $this->initProducts(); - } else { - $collProducts = ProductQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - return $collProducts; - } - $this->collProducts = $collProducts; - } - } - - return $this->collProducts; - } - - /** - * Sets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $products A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setProducts(PropelCollection $products, PropelPDO $con = null) - { - $this->clearProducts(); - $currentProducts = $this->getProducts(); - - $this->productsScheduledForDeletion = $currentProducts->diff($products); - - foreach ($products as $product) { - if (!$currentProducts->contains($product)) { - $this->doAddProduct($product); - } - } - - $this->collProducts = $products; - - return $this; - } - - /** - * Gets the number of Product objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Product objects - */ - public function countProducts($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collProducts || null !== $criteria) { - if ($this->isNew() && null === $this->collProducts) { - return 0; - } else { - $query = ProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collProducts); - } - } - - /** - * Associate a Product object to this object - * through the product_category cross reference table. - * - * @param Product $product The ProductCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function addProduct(Product $product) - { - if ($this->collProducts === null) { - $this->initProducts(); - } - if (!$this->collProducts->contains($product)) { // only add it if the **same** object is not already associated - $this->doAddProduct($product); - - $this->collProducts[]= $product; - } - - return $this; - } - - /** - * @param Product $product The product object to add. - */ - protected function doAddProduct($product) - { - $productCategory = new ProductCategory(); - $productCategory->setProduct($product); - $this->addProductCategory($productCategory); - } - - /** - * Remove a Product object to this object - * through the product_category cross reference table. - * - * @param Product $product The ProductCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function removeProduct(Product $product) - { - if ($this->getProducts()->contains($product)) { - $this->collProducts->remove($this->collProducts->search($product)); - if (null === $this->productsScheduledForDeletion) { - $this->productsScheduledForDeletion = clone $this->collProducts; - $this->productsScheduledForDeletion->clear(); - } - $this->productsScheduledForDeletion[]= $product; - } - - return $this; - } - - /** - * Clears out the collFeatures 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 Category The current object (for fluent API support) - * @see addFeatures() - */ - public function clearFeatures() - { - $this->collFeatures = null; // important to set this to null since that means it is uninitialized - $this->collFeaturesPartial = null; - - return $this; - } - - /** - * Initializes the collFeatures collection. - * - * By default this just sets the collFeatures collection to an empty collection (like clearFeatures()); - * 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. - * - * @return void - */ - public function initFeatures() - { - $this->collFeatures = new PropelObjectCollection(); - $this->collFeatures->setModel('Feature'); - } - - /** - * Gets a collection of Feature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Feature[] List of Feature objects - */ - public function getFeatures($criteria = null, PropelPDO $con = null) - { - if (null === $this->collFeatures || null !== $criteria) { - if ($this->isNew() && null === $this->collFeatures) { - // return empty collection - $this->initFeatures(); - } else { - $collFeatures = FeatureQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - return $collFeatures; - } - $this->collFeatures = $collFeatures; - } - } - - return $this->collFeatures; - } - - /** - * Sets a collection of Feature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * 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 $features A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setFeatures(PropelCollection $features, PropelPDO $con = null) - { - $this->clearFeatures(); - $currentFeatures = $this->getFeatures(); - - $this->featuresScheduledForDeletion = $currentFeatures->diff($features); - - foreach ($features as $feature) { - if (!$currentFeatures->contains($feature)) { - $this->doAddFeature($feature); - } - } - - $this->collFeatures = $features; - - return $this; - } - - /** - * Gets the number of Feature objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Feature objects - */ - public function countFeatures($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collFeatures || null !== $criteria) { - if ($this->isNew() && null === $this->collFeatures) { - return 0; - } else { - $query = FeatureQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collFeatures); - } - } - - /** - * Associate a Feature object to this object - * through the feature_category cross reference table. - * - * @param Feature $feature The FeatureCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function addFeature(Feature $feature) - { - if ($this->collFeatures === null) { - $this->initFeatures(); - } - if (!$this->collFeatures->contains($feature)) { // only add it if the **same** object is not already associated - $this->doAddFeature($feature); - - $this->collFeatures[]= $feature; - } - - return $this; - } - - /** - * @param Feature $feature The feature object to add. - */ - protected function doAddFeature($feature) - { - $featureCategory = new FeatureCategory(); - $featureCategory->setFeature($feature); - $this->addFeatureCategory($featureCategory); - } - - /** - * Remove a Feature object to this object - * through the feature_category cross reference table. - * - * @param Feature $feature The FeatureCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function removeFeature(Feature $feature) - { - if ($this->getFeatures()->contains($feature)) { - $this->collFeatures->remove($this->collFeatures->search($feature)); - if (null === $this->featuresScheduledForDeletion) { - $this->featuresScheduledForDeletion = clone $this->collFeatures; - $this->featuresScheduledForDeletion->clear(); - } - $this->featuresScheduledForDeletion[]= $feature; - } - - return $this; - } - - /** - * Clears out the collAttributes 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 Category The current object (for fluent API support) - * @see addAttributes() - */ - public function clearAttributes() - { - $this->collAttributes = null; // important to set this to null since that means it is uninitialized - $this->collAttributesPartial = null; - - return $this; - } - - /** - * Initializes the collAttributes collection. - * - * By default this just sets the collAttributes collection to an empty collection (like clearAttributes()); - * 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. - * - * @return void - */ - public function initAttributes() - { - $this->collAttributes = new PropelObjectCollection(); - $this->collAttributes->setModel('Attribute'); - } - - /** - * Gets a collection of Attribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Attribute[] List of Attribute objects - */ - public function getAttributes($criteria = null, PropelPDO $con = null) - { - if (null === $this->collAttributes || null !== $criteria) { - if ($this->isNew() && null === $this->collAttributes) { - // return empty collection - $this->initAttributes(); - } else { - $collAttributes = AttributeQuery::create(null, $criteria) - ->filterByCategory($this) - ->find($con); - if (null !== $criteria) { - return $collAttributes; - } - $this->collAttributes = $collAttributes; - } - } - - return $this->collAttributes; - } - - /** - * Sets a collection of Attribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * 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 $attributes A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Category The current object (for fluent API support) - */ - public function setAttributes(PropelCollection $attributes, PropelPDO $con = null) - { - $this->clearAttributes(); - $currentAttributes = $this->getAttributes(); - - $this->attributesScheduledForDeletion = $currentAttributes->diff($attributes); - - foreach ($attributes as $attribute) { - if (!$currentAttributes->contains($attribute)) { - $this->doAddAttribute($attribute); - } - } - - $this->collAttributes = $attributes; - - return $this; - } - - /** - * Gets the number of Attribute objects related by a many-to-many relationship - * to the current object by way of the attribute_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Attribute objects - */ - public function countAttributes($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collAttributes || null !== $criteria) { - if ($this->isNew() && null === $this->collAttributes) { - return 0; - } else { - $query = AttributeQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCategory($this) - ->count($con); - } - } else { - return count($this->collAttributes); - } - } - - /** - * Associate a Attribute object to this object - * through the attribute_category cross reference table. - * - * @param Attribute $attribute The AttributeCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function addAttribute(Attribute $attribute) - { - if ($this->collAttributes === null) { - $this->initAttributes(); - } - if (!$this->collAttributes->contains($attribute)) { // only add it if the **same** object is not already associated - $this->doAddAttribute($attribute); - - $this->collAttributes[]= $attribute; - } - - return $this; - } - - /** - * @param Attribute $attribute The attribute object to add. - */ - protected function doAddAttribute($attribute) - { - $attributeCategory = new AttributeCategory(); - $attributeCategory->setAttribute($attribute); - $this->addAttributeCategory($attributeCategory); - } - - /** - * Remove a Attribute object to this object - * through the attribute_category cross reference table. - * - * @param Attribute $attribute The AttributeCategory object to relate - * @return Category The current object (for fluent API support) - */ - public function removeAttribute(Attribute $attribute) - { - if ($this->getAttributes()->contains($attribute)) { - $this->collAttributes->remove($this->collAttributes->search($attribute)); - if (null === $this->attributesScheduledForDeletion) { - $this->attributesScheduledForDeletion = clone $this->collAttributes; - $this->attributesScheduledForDeletion->clear(); - } - $this->attributesScheduledForDeletion[]= $attribute; - } - - return $this; - } - - /** - * 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collProductCategorys) { - foreach ($this->collProductCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureCategorys) { - foreach ($this->collFeatureCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributeCategorys) { - foreach ($this->collAttributeCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCategoryI18ns) { - foreach ($this->collCategoryI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCategoryVersions) { - foreach ($this->collCategoryVersions as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProducts) { - foreach ($this->collProducts as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatures) { - foreach ($this->collFeatures as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAttributes) { - foreach ($this->collAttributes as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collProductCategorys instanceof PropelCollection) { - $this->collProductCategorys->clearIterator(); - } - $this->collProductCategorys = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); - } - $this->collFeatureCategorys = null; - if ($this->collAttributeCategorys instanceof PropelCollection) { - $this->collAttributeCategorys->clearIterator(); - } - $this->collAttributeCategorys = null; - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; - if ($this->collCategoryI18ns instanceof PropelCollection) { - $this->collCategoryI18ns->clearIterator(); - } - $this->collCategoryI18ns = null; - if ($this->collCategoryVersions instanceof PropelCollection) { - $this->collCategoryVersions->clearIterator(); - } - $this->collCategoryVersions = null; - if ($this->collProducts instanceof PropelCollection) { - $this->collProducts->clearIterator(); - } - $this->collProducts = null; - if ($this->collFeatures instanceof PropelCollection) { - $this->collFeatures->clearIterator(); - } - $this->collFeatures = null; - if ($this->collAttributes instanceof PropelCollection) { - $this->collAttributes->clearIterator(); - } - $this->collAttributes = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CategoryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Category The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CategoryPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Category The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return CategoryI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collCategoryI18ns) { - foreach ($this->collCategoryI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new CategoryI18n(); - $translation->setLocale($locale); - } else { - $translation = CategoryI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addCategoryI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Category The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - CategoryI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collCategoryI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collCategoryI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return CategoryI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - 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/BaseCategoryI18n.php b/core/lib/Thelia/Model/om/BaseCategoryI18n.php deleted file mode 100755 index 0a609b481..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseCategoryI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CategoryI18nPeer::ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = CategoryI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = CategoryI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = CategoryI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = CategoryI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return CategoryI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = CategoryI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = CategoryI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CategoryI18n 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(CategoryI18nPeer::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 = CategoryI18nPeer::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(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CategoryI18nQuery::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(CategoryI18nPeer::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); - CategoryI18nPeer::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(CategoryI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CategoryI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(CategoryI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(CategoryI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(CategoryI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(CategoryI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `category_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $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 = CategoryI18nPeer::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 = CategoryI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['CategoryI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CategoryI18n'][serialize($this->getPrimaryKey())] = true; - $keys = CategoryI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - 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 = CategoryI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = CategoryI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CategoryI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(CategoryI18nPeer::ID)) $criteria->add(CategoryI18nPeer::ID, $this->id); - if ($this->isColumnModified(CategoryI18nPeer::LOCALE)) $criteria->add(CategoryI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(CategoryI18nPeer::TITLE)) $criteria->add(CategoryI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(CategoryI18nPeer::DESCRIPTION)) $criteria->add(CategoryI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CategoryI18nPeer::CHAPO)) $criteria->add(CategoryI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(CategoryI18nPeer::POSTSCRIPTUM)) $criteria->add(CategoryI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(CategoryI18nPeer::DATABASE_NAME); - $criteria->add(CategoryI18nPeer::ID, $this->id); - $criteria->add(CategoryI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 CategoryI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 CategoryI18n 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 CategoryI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CategoryI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return CategoryI18n 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->addCategoryI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->addCategoryI18ns($this); - */ - } - - return $this->aCategory; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCategory = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CategoryI18nPeer::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/BaseCategoryI18nPeer.php b/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php deleted file mode 100755 index c71c16bc8..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (CategoryI18nPeer::ID, CategoryI18nPeer::LOCALE, CategoryI18nPeer::TITLE, CategoryI18nPeer::DESCRIPTION, CategoryI18nPeer::CHAPO, CategoryI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CategoryI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (CategoryI18nPeer::ID => 0, CategoryI18nPeer::LOCALE => 1, CategoryI18nPeer::TITLE => 2, CategoryI18nPeer::DESCRIPTION => 3, CategoryI18nPeer::CHAPO => 4, CategoryI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CategoryI18nPeer::getFieldNames($toType); - $key = isset(CategoryI18nPeer::$fieldKeys[$fromType][$name]) ? CategoryI18nPeer::$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(CategoryI18nPeer::$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, CategoryI18nPeer::$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 CategoryI18nPeer::$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. CategoryI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CategoryI18nPeer::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(CategoryI18nPeer::ID); - $criteria->addSelectColumn(CategoryI18nPeer::LOCALE); - $criteria->addSelectColumn(CategoryI18nPeer::TITLE); - $criteria->addSelectColumn(CategoryI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(CategoryI18nPeer::CHAPO); - $criteria->addSelectColumn(CategoryI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(CategoryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CategoryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CategoryI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CategoryI18nPeer::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 CategoryI18n - * @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 = CategoryI18nPeer::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 CategoryI18nPeer::populateObjects(CategoryI18nPeer::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 directly (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(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CategoryI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CategoryI18nPeer::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 CategoryI18n $obj A CategoryI18n 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->getLocale())); - } // if key === null - CategoryI18nPeer::$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 CategoryI18n 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 CategoryI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 CategoryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CategoryI18nPeer::$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 CategoryI18n 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(CategoryI18nPeer::$instances[$key])) { - return CategoryI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CategoryI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CategoryI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to category_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CategoryI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CategoryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CategoryI18nPeer::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; - CategoryI18nPeer::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 (CategoryI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CategoryI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CategoryI18nPeer::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 + CategoryI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CategoryI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CategoryI18nPeer::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(CategoryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CategoryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CategoryI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CategoryI18nPeer::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 CategoryI18n 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 CategoryI18n 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(CategoryI18nPeer::DATABASE_NAME); - } - - CategoryI18nPeer::addSelectColumns($criteria); - $startcol = CategoryI18nPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(CategoryI18nPeer::ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CategoryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CategoryI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CategoryI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CategoryI18nPeer::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 (CategoryI18n) to $obj2 (Category) - $obj2->addCategoryI18n($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(CategoryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CategoryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CategoryI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CategoryI18nPeer::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 CategoryI18n 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 CategoryI18n 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(CategoryI18nPeer::DATABASE_NAME); - } - - CategoryI18nPeer::addSelectColumns($criteria); - $startcol2 = CategoryI18nPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CategoryI18nPeer::ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CategoryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CategoryI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CategoryI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CategoryI18nPeer::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 (CategoryI18n) to the collection in $obj2 (Category) - $obj2->addCategoryI18n($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(CategoryI18nPeer::DATABASE_NAME)->getTable(CategoryI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCategoryI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCategoryI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CategoryI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CategoryI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CategoryI18n or Criteria object. - * - * @param mixed $values Criteria or CategoryI18n 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(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CategoryI18n object - } - - - // Set the correct dbName - $criteria->setDbName(CategoryI18nPeer::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 CategoryI18n or Criteria object. - * - * @param mixed $values Criteria or CategoryI18n 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(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CategoryI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CategoryI18nPeer::ID); - $value = $criteria->remove(CategoryI18nPeer::ID); - if ($value) { - $selectCriteria->add(CategoryI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CategoryI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(CategoryI18nPeer::LOCALE); - $value = $criteria->remove(CategoryI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(CategoryI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CategoryI18nPeer::TABLE_NAME); - } - - } else { // $values is CategoryI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CategoryI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the category_i18n 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(CategoryI18nPeer::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(CategoryI18nPeer::TABLE_NAME, $con, CategoryI18nPeer::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). - CategoryI18nPeer::clearInstancePool(); - CategoryI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CategoryI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CategoryI18n 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(CategoryI18nPeer::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. - CategoryI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CategoryI18n) { // it's a model object - // invalidate the cache for this single object - CategoryI18nPeer::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(CategoryI18nPeer::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(CategoryI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(CategoryI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - CategoryI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(CategoryI18nPeer::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); - CategoryI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CategoryI18n 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 CategoryI18n $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(CategoryI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CategoryI18nPeer::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(CategoryI18nPeer::DATABASE_NAME, CategoryI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return CategoryI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = CategoryI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CategoryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(CategoryI18nPeer::DATABASE_NAME); - $criteria->add(CategoryI18nPeer::ID, $id); - $criteria->add(CategoryI18nPeer::LOCALE, $locale); - $v = CategoryI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseCategoryI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCategoryI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php b/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php deleted file mode 100755 index 50d754e67..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return CategoryI18n|CategoryI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CategoryI18nPeer::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(CategoryI18nPeer::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 CategoryI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `category_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 CategoryI18n(); - $obj->hydrate($row); - CategoryI18nPeer::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 CategoryI18n|CategoryI18n[]|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|CategoryI18n[]|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 CategoryI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(CategoryI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(CategoryI18nPeer::LOCALE, $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 CategoryI18nQuery 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(CategoryI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(CategoryI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 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 CategoryI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CategoryI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CategoryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 CategoryI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryI18nPeer::POSTSCRIPTUM, $postscriptum, $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 CategoryI18nQuery 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(CategoryI18nPeer::ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CategoryI18nPeer::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 CategoryI18nQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Exclude object from result - * - * @param CategoryI18n $categoryI18n Object to remove from the list of results - * - * @return CategoryI18nQuery The current query, for fluid interface - */ - public function prune($categoryI18n = null) - { - if ($categoryI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(CategoryI18nPeer::ID), $categoryI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(CategoryI18nPeer::LOCALE), $categoryI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCategoryPeer.php b/core/lib/Thelia/Model/om/BaseCategoryPeer.php deleted file mode 100755 index d2defdbf5..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryPeer.php +++ /dev/null @@ -1,893 +0,0 @@ - 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, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, '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, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CategoryPeer::getFieldNames($toType); - $key = isset(CategoryPeer::$fieldKeys[$fromType][$name]) ? CategoryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CategoryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CategoryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CategoryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CategoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CategoryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CategoryPeer::ID); - $criteria->addSelectColumn(CategoryPeer::PARENT); - $criteria->addSelectColumn(CategoryPeer::LINK); - $criteria->addSelectColumn(CategoryPeer::VISIBLE); - $criteria->addSelectColumn(CategoryPeer::POSITION); - $criteria->addSelectColumn(CategoryPeer::CREATED_AT); - $criteria->addSelectColumn(CategoryPeer::UPDATED_AT); - $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'); - $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(CategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CategoryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Category - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CategoryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CategoryPeer::populateObjects(CategoryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CategoryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CategoryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Category $obj A Category object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CategoryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Category object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Category) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Category object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CategoryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Category Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CategoryPeer::$instances[$key])) { - return CategoryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CategoryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CategoryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to category - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ProductCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ProductCategoryPeer::clearInstancePool(); - // Invalidate objects in FeatureCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureCategoryPeer::clearInstancePool(); - // Invalidate objects in AttributeCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCategoryPeer::clearInstancePool(); - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in RewritingPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingPeer::clearInstancePool(); - // 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(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CategoryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CategoryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Category object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CategoryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CategoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CategoryPeer::DATABASE_NAME)->getTable(CategoryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCategoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCategoryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CategoryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CategoryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Category or Criteria object. - * - * @param mixed $values Criteria or Category object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Category object - } - - if ($criteria->containsKey(CategoryPeer::ID) && $criteria->keyContainsValue(CategoryPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CategoryPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CategoryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Category or Criteria object. - * - * @param mixed $values Criteria or Category object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CategoryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CategoryPeer::ID); - $value = $criteria->remove(CategoryPeer::ID); - if ($value) { - $selectCriteria->add(CategoryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CategoryPeer::TABLE_NAME); - } - - } else { // $values is Category object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CategoryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the category table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CategoryPeer::TABLE_NAME, $con, CategoryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CategoryPeer::clearInstancePool(); - CategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Category or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Category object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CategoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Category) { // it's a model object - // invalidate the cache for this single object - CategoryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); - $criteria->add(CategoryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CategoryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CategoryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Category object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Category $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CategoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CategoryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CategoryPeer::DATABASE_NAME, CategoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Category - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CategoryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); - $criteria->add(CategoryPeer::ID, $pk); - - $v = CategoryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Category[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CategoryPeer::DATABASE_NAME); - $criteria->add(CategoryPeer::ID, $pks, Criteria::IN); - $objs = CategoryPeer::doSelect($criteria, $con); - } - - return $objs; - } - - // 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. -// -BaseCategoryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCategoryQuery.php b/core/lib/Thelia/Model/om/BaseCategoryQuery.php deleted file mode 100755 index dd7550fae..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryQuery.php +++ /dev/null @@ -1,1565 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Category|Category[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Category A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Category A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `category` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Category(); - $obj->hydrate($row); - CategoryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Category|Category[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Category[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CategoryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CategoryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 - * - * - * @param mixed $parent The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByParent($parent = null, $comparison = null) - { - if (is_array($parent)) { - $useMinMax = false; - if (isset($parent['min'])) { - $this->addUsingAlias(CategoryPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($parent['max'])) { - $this->addUsingAlias(CategoryPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::PARENT, $parent, $comparison); - } - - /** - * Filter the query on the link column - * - * Example usage: - * - * $query->filterByLink('fooValue'); // WHERE link = 'fooValue' - * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%' - * - * - * @param string $link The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByLink($link = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($link)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $link)) { - $link = str_replace('*', '%', $link); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CategoryPeer::LINK, $link, $comparison); - } - - /** - * Filter the query on the visible column - * - * Example usage: - * - * $query->filterByVisible(1234); // WHERE visible = 1234 - * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 - * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 - * - * - * @param mixed $visible The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByVisible($visible = null, $comparison = null) - { - if (is_array($visible)) { - $useMinMax = false; - if (isset($visible['min'])) { - $this->addUsingAlias(CategoryPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($visible['max'])) { - $this->addUsingAlias(CategoryPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::VISIBLE, $visible, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(CategoryPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(CategoryPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query 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 - * $query->filterByVersion(array('max' => 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 - * - * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProductCategory($productCategory, $comparison = null) - { - if ($productCategory instanceof ProductCategory) { - return $this - ->addUsingAlias(CategoryPeer::ID, $productCategory->getCategoryId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { - return $this - ->useProductCategoryQuery() - ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductCategory'); - } - - return $this; - } - - /** - * Use the ProductCategory relation ProductCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query - */ - public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); - } - - /** - * Filter the query by a related FeatureCategory object - * - * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureCategory($featureCategory, $comparison = null) - { - if ($featureCategory instanceof FeatureCategory) { - return $this - ->addUsingAlias(CategoryPeer::ID, $featureCategory->getCategoryId(), $comparison); - } elseif ($featureCategory instanceof PropelObjectCollection) { - return $this - ->useFeatureCategoryQuery() - ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureCategory'); - } - - return $this; - } - - /** - * Use the FeatureCategory relation FeatureCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query - */ - public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); - } - - /** - * Filter the query by a related AttributeCategory object - * - * @param AttributeCategory|PropelObjectCollection $attributeCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeCategory($attributeCategory, $comparison = null) - { - if ($attributeCategory instanceof AttributeCategory) { - return $this - ->addUsingAlias(CategoryPeer::ID, $attributeCategory->getCategoryId(), $comparison); - } elseif ($attributeCategory instanceof PropelObjectCollection) { - return $this - ->useAttributeCategoryQuery() - ->filterByPrimaryKeys($attributeCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCategory() only accepts arguments of type AttributeCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinAttributeCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCategory'); - } - - return $this; - } - - /** - * Use the AttributeCategory relation AttributeCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCategoryQuery A secondary query class using the current class as primary query - */ - public function useAttributeCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCategory', '\Thelia\Model\AttributeCategoryQuery'); - } - - /** - * Filter the query by a related ContentAssoc object - * - * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof ContentAssoc) { - return $this - ->addUsingAlias(CategoryPeer::ID, $contentAssoc->getCategoryId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - - /** - * Filter the query by a related Image object - * - * @param Image|PropelObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(CategoryPeer::ID, $image->getCategoryId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related Document object - * - * @param Document|PropelObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(CategoryPeer::ID, $document->getCategoryId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Filter the query by a related Rewriting object - * - * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof Rewriting) { - return $this - ->addUsingAlias(CategoryPeer::ID, $rewriting->getCategoryId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - - /** - * Filter the query by a related CategoryI18n object - * - * @param CategoryI18n|PropelObjectCollection $categoryI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategoryI18n($categoryI18n, $comparison = null) - { - if ($categoryI18n instanceof CategoryI18n) { - return $this - ->addUsingAlias(CategoryPeer::ID, $categoryI18n->getId(), $comparison); - } elseif ($categoryI18n instanceof PropelObjectCollection) { - return $this - ->useCategoryI18nQuery() - ->filterByPrimaryKeys($categoryI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCategoryI18n() only accepts arguments of type CategoryI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CategoryI18n 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 joinCategoryI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CategoryI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CategoryI18n'); - } - - return $this; - } - - /** - * Use the CategoryI18n relation CategoryI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryI18nQuery A secondary query class using the current class as primary query - */ - public function useCategoryI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCategoryI18n($relationAlias, $joinType) - ->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'); - } - - /** - * Filter the query by a related Product object - * using the product_category table as cross reference - * - * @param Product $product 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 - */ - public function filterByProduct($product, $comparison = Criteria::EQUAL) - { - return $this - ->useProductCategoryQuery() - ->filterByProduct($product, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Feature object - * using the feature_category table as cross reference - * - * @param Feature $feature 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 - */ - public function filterByFeature($feature, $comparison = Criteria::EQUAL) - { - return $this - ->useFeatureCategoryQuery() - ->filterByFeature($feature, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Attribute object - * using the attribute_category table as cross reference - * - * @param Attribute $attribute 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 - */ - public function filterByAttribute($attribute, $comparison = Criteria::EQUAL) - { - return $this - ->useAttributeCategoryQuery() - ->filterByAttribute($attribute, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Category $category Object to remove from the list of results - * - * @return CategoryQuery The current query, for fluid interface - */ - public function prune($category = null) - { - if ($category) { - $this->addUsingAlias(CategoryPeer::ID, $category->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CategoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CategoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CategoryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CategoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CategoryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CategoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CategoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CategoryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CategoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CategoryPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; - - return $this - ->joinCategoryI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CategoryQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('CategoryI18n'); - $this->with['CategoryI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CategoryI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CategoryI18n', 'Thelia\Model\CategoryI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCategoryVersion.php b/core/lib/Thelia/Model/om/BaseCategoryVersion.php deleted file mode 100755 index 72a5028ac..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryVersion.php +++ /dev/null @@ -1,1505 +0,0 @@ -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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - 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; - } - - $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. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // 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 deleted file mode 100755 index c3534e664..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryVersionPeer.php +++ /dev/null @@ -1,1036 +0,0 @@ - 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 directly (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($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CategoryVersionPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - 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($row = 0, $colnum = 0) - { - 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 deleted file mode 100755 index 957c2ee50..000000000 --- a/core/lib/Thelia/Model/om/BaseCategoryVersionQuery.php +++ /dev/null @@ -1,763 +0,0 @@ -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 - * $query->filterById(array('max' => 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)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CategoryVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CategoryVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryVersionPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByParent(array('max' => 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 - * $query->filterByVisible(array('max' => 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 - * $query->filterByPosition(array('max' => 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 - * $query->filterByVersion(array('max' => 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)) { - $useMinMax = false; - if (isset($version['min'])) { - $this->addUsingAlias(CategoryVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($version['max'])) { - $this->addUsingAlias(CategoryVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CategoryVersionPeer::VERSION, $version, $comparison); - } - - /** - * 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/BaseCombination.php b/core/lib/Thelia/Model/om/BaseCombination.php deleted file mode 100755 index a05fa4e5c..000000000 --- a/core/lib/Thelia/Model/om/BaseCombination.php +++ /dev/null @@ -1,1698 +0,0 @@ -id; - } - - /** - * Get the [ref] column value. - * - * @return string - */ - public function getRef() - { - return $this->ref; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Combination The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CombinationPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return Combination The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = CombinationPeer::REF; - } - - - return $this; - } // setRef() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Combination The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CombinationPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Combination The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CombinationPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = CombinationPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Combination object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CombinationPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAttributeCombinations = null; - - $this->collStocks = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CombinationQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CombinationPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CombinationPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CombinationPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CombinationPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->attributeCombinationsScheduledForDeletion !== null) { - if (!$this->attributeCombinationsScheduledForDeletion->isEmpty()) { - AttributeCombinationQuery::create() - ->filterByPrimaryKeys($this->attributeCombinationsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->attributeCombinationsScheduledForDeletion = null; - } - } - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->stocksScheduledForDeletion !== null) { - if (!$this->stocksScheduledForDeletion->isEmpty()) { - foreach ($this->stocksScheduledForDeletion as $stock) { - // need to save related object because we set the relation to null - $stock->save($con); - } - $this->stocksScheduledForDeletion = null; - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CombinationPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CombinationPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CombinationPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CombinationPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; - } - if ($this->isColumnModified(CombinationPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `combination` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`ref`': - $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CombinationPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAttributeCombinations !== null) { - foreach ($this->collAttributeCombinations as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getRef(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Combination'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Combination'][$this->getPrimaryKey()] = true; - $keys = CombinationPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getRef(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collAttributeCombinations) { - $result['AttributeCombinations'] = $this->collAttributeCombinations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collStocks) { - $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CombinationPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setRef($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CombinationPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - - if ($this->isColumnModified(CombinationPeer::ID)) $criteria->add(CombinationPeer::ID, $this->id); - if ($this->isColumnModified(CombinationPeer::REF)) $criteria->add(CombinationPeer::REF, $this->ref); - if ($this->isColumnModified(CombinationPeer::CREATED_AT)) $criteria->add(CombinationPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CombinationPeer::UPDATED_AT)) $criteria->add(CombinationPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - $criteria->add(CombinationPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Combination (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setRef($this->getRef()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAttributeCombinations() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAttributeCombination($relObj->copy($deepCopy)); - } - } - - foreach ($this->getStocks() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addStock($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Combination Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CombinationPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CombinationPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AttributeCombination' == $relationName) { - $this->initAttributeCombinations(); - } - if ('Stock' == $relationName) { - $this->initStocks(); - } - } - - /** - * Clears out the collAttributeCombinations collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Combination The current object (for fluent API support) - * @see addAttributeCombinations() - */ - public function clearAttributeCombinations() - { - $this->collAttributeCombinations = null; // important to set this to null since that means it is uninitialized - $this->collAttributeCombinationsPartial = null; - - return $this; - } - - /** - * reset is the collAttributeCombinations collection loaded partially - * - * @return void - */ - public function resetPartialAttributeCombinations($v = true) - { - $this->collAttributeCombinationsPartial = $v; - } - - /** - * Initializes the collAttributeCombinations collection. - * - * By default this just sets the collAttributeCombinations collection to an empty array (like clearcollAttributeCombinations()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAttributeCombinations($overrideExisting = true) - { - if (null !== $this->collAttributeCombinations && !$overrideExisting) { - return; - } - $this->collAttributeCombinations = new PropelObjectCollection(); - $this->collAttributeCombinations->setModel('AttributeCombination'); - } - - /** - * Gets an array of AttributeCombination objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Combination is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - * @throws PropelException - */ - public function getAttributeCombinations($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - // return empty collection - $this->initAttributeCombinations(); - } else { - $collAttributeCombinations = AttributeCombinationQuery::create(null, $criteria) - ->filterByCombination($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAttributeCombinationsPartial && count($collAttributeCombinations)) { - $this->initAttributeCombinations(false); - - foreach($collAttributeCombinations as $obj) { - if (false == $this->collAttributeCombinations->contains($obj)) { - $this->collAttributeCombinations->append($obj); - } - } - - $this->collAttributeCombinationsPartial = true; - } - - $collAttributeCombinations->getInternalIterator()->rewind(); - return $collAttributeCombinations; - } - - if($partial && $this->collAttributeCombinations) { - foreach($this->collAttributeCombinations as $obj) { - if($obj->isNew()) { - $collAttributeCombinations[] = $obj; - } - } - } - - $this->collAttributeCombinations = $collAttributeCombinations; - $this->collAttributeCombinationsPartial = false; - } - } - - return $this->collAttributeCombinations; - } - - /** - * Sets a collection of AttributeCombination objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $attributeCombinations A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Combination The current object (for fluent API support) - */ - public function setAttributeCombinations(PropelCollection $attributeCombinations, PropelPDO $con = null) - { - $attributeCombinationsToDelete = $this->getAttributeCombinations(new Criteria(), $con)->diff($attributeCombinations); - - $this->attributeCombinationsScheduledForDeletion = unserialize(serialize($attributeCombinationsToDelete)); - - foreach ($attributeCombinationsToDelete as $attributeCombinationRemoved) { - $attributeCombinationRemoved->setCombination(null); - } - - $this->collAttributeCombinations = null; - foreach ($attributeCombinations as $attributeCombination) { - $this->addAttributeCombination($attributeCombination); - } - - $this->collAttributeCombinations = $attributeCombinations; - $this->collAttributeCombinationsPartial = false; - - return $this; - } - - /** - * Returns the number of related AttributeCombination objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AttributeCombination objects. - * @throws PropelException - */ - public function countAttributeCombinations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAttributeCombinationsPartial && !$this->isNew(); - if (null === $this->collAttributeCombinations || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAttributeCombinations) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAttributeCombinations()); - } - $query = AttributeCombinationQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); - } - - return count($this->collAttributeCombinations); - } - - /** - * Method called to associate a AttributeCombination object to this object - * through the AttributeCombination foreign key attribute. - * - * @param AttributeCombination $l AttributeCombination - * @return Combination The current object (for fluent API support) - */ - public function addAttributeCombination(AttributeCombination $l) - { - if ($this->collAttributeCombinations === null) { - $this->initAttributeCombinations(); - $this->collAttributeCombinationsPartial = true; - } - if (!in_array($l, $this->collAttributeCombinations->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAttributeCombination($l); - } - - return $this; - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to add. - */ - protected function doAddAttributeCombination($attributeCombination) - { - $this->collAttributeCombinations[]= $attributeCombination; - $attributeCombination->setCombination($this); - } - - /** - * @param AttributeCombination $attributeCombination The attributeCombination object to remove. - * @return Combination The current object (for fluent API support) - */ - public function removeAttributeCombination($attributeCombination) - { - if ($this->getAttributeCombinations()->contains($attributeCombination)) { - $this->collAttributeCombinations->remove($this->collAttributeCombinations->search($attributeCombination)); - if (null === $this->attributeCombinationsScheduledForDeletion) { - $this->attributeCombinationsScheduledForDeletion = clone $this->collAttributeCombinations; - $this->attributeCombinationsScheduledForDeletion->clear(); - } - $this->attributeCombinationsScheduledForDeletion[]= clone $attributeCombination; - $attributeCombination->setCombination(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinAttribute($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('Attribute', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related AttributeCombinations from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AttributeCombination[] List of AttributeCombination objects - */ - public function getAttributeCombinationsJoinAttributeAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AttributeCombinationQuery::create(null, $criteria); - $query->joinWith('AttributeAv', $join_behavior); - - return $this->getAttributeCombinations($query, $con); - } - - /** - * Clears out the collStocks collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Combination The current object (for fluent API support) - * @see addStocks() - */ - public function clearStocks() - { - $this->collStocks = null; // important to set this to null since that means it is uninitialized - $this->collStocksPartial = null; - - return $this; - } - - /** - * reset is the collStocks collection loaded partially - * - * @return void - */ - public function resetPartialStocks($v = true) - { - $this->collStocksPartial = $v; - } - - /** - * Initializes the collStocks collection. - * - * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initStocks($overrideExisting = true) - { - if (null !== $this->collStocks && !$overrideExisting) { - return; - } - $this->collStocks = new PropelObjectCollection(); - $this->collStocks->setModel('Stock'); - } - - /** - * Gets an array of Stock objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Combination is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Stock[] List of Stock objects - * @throws PropelException - */ - public function getStocks($criteria = null, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - // return empty collection - $this->initStocks(); - } else { - $collStocks = StockQuery::create(null, $criteria) - ->filterByCombination($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); - - foreach($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); - } - } - - $this->collStocksPartial = true; - } - - $collStocks->getInternalIterator()->rewind(); - return $collStocks; - } - - if($partial && $this->collStocks) { - foreach($this->collStocks as $obj) { - if($obj->isNew()) { - $collStocks[] = $obj; - } - } - } - - $this->collStocks = $collStocks; - $this->collStocksPartial = false; - } - } - - return $this->collStocks; - } - - /** - * Sets a collection of Stock objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $stocks A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Combination The current object (for fluent API support) - */ - public function setStocks(PropelCollection $stocks, PropelPDO $con = null) - { - $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - - $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); - - foreach ($stocksToDelete as $stockRemoved) { - $stockRemoved->setCombination(null); - } - - $this->collStocks = null; - foreach ($stocks as $stock) { - $this->addStock($stock); - } - - $this->collStocks = $stocks; - $this->collStocksPartial = false; - - return $this; - } - - /** - * Returns the number of related Stock objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Stock objects. - * @throws PropelException - */ - public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getStocks()); - } - $query = StockQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCombination($this) - ->count($con); - } - - return count($this->collStocks); - } - - /** - * Method called to associate a Stock object to this object - * through the Stock foreign key attribute. - * - * @param Stock $l Stock - * @return Combination The current object (for fluent API support) - */ - public function addStock(Stock $l) - { - if ($this->collStocks === null) { - $this->initStocks(); - $this->collStocksPartial = true; - } - if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddStock($l); - } - - return $this; - } - - /** - * @param Stock $stock The stock object to add. - */ - protected function doAddStock($stock) - { - $this->collStocks[]= $stock; - $stock->setCombination($this); - } - - /** - * @param Stock $stock The stock object to remove. - * @return Combination The current object (for fluent API support) - */ - public function removeStock($stock) - { - if ($this->getStocks()->contains($stock)) { - $this->collStocks->remove($this->collStocks->search($stock)); - if (null === $this->stocksScheduledForDeletion) { - $this->stocksScheduledForDeletion = clone $this->collStocks; - $this->stocksScheduledForDeletion->clear(); - } - $this->stocksScheduledForDeletion[]= $stock; - $stock->setCombination(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Combination is new, it will return - * an empty collection; or if this Combination has previously - * been saved, it will retrieve related Stocks from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Combination. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Stock[] List of Stock objects - */ - public function getStocksJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = StockQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getStocks($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->ref = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAttributeCombinations) { - foreach ($this->collAttributeCombinations as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collStocks) { - foreach ($this->collStocks as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collAttributeCombinations instanceof PropelCollection) { - $this->collAttributeCombinations->clearIterator(); - } - $this->collAttributeCombinations = null; - if ($this->collStocks instanceof PropelCollection) { - $this->collStocks->clearIterator(); - } - $this->collStocks = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CombinationPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Combination The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CombinationPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCombinationPeer.php b/core/lib/Thelia/Model/om/BaseCombinationPeer.php deleted file mode 100755 index bb2557aa9..000000000 --- a/core/lib/Thelia/Model/om/BaseCombinationPeer.php +++ /dev/null @@ -1,793 +0,0 @@ - array ('Id', 'Ref', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CombinationPeer::ID, CombinationPeer::REF, CombinationPeer::CREATED_AT, CombinationPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CombinationPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (CombinationPeer::ID => 0, CombinationPeer::REF => 1, CombinationPeer::CREATED_AT => 2, CombinationPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CombinationPeer::getFieldNames($toType); - $key = isset(CombinationPeer::$fieldKeys[$fromType][$name]) ? CombinationPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CombinationPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CombinationPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CombinationPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CombinationPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CombinationPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CombinationPeer::ID); - $criteria->addSelectColumn(CombinationPeer::REF); - $criteria->addSelectColumn(CombinationPeer::CREATED_AT); - $criteria->addSelectColumn(CombinationPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.ref'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CombinationPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CombinationPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CombinationPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Combination - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CombinationPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CombinationPeer::populateObjects(CombinationPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CombinationPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CombinationPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Combination $obj A Combination object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CombinationPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Combination object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Combination) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Combination object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CombinationPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Combination Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CombinationPeer::$instances[$key])) { - return CombinationPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CombinationPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CombinationPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to combination - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AttributeCombinationPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AttributeCombinationPeer::clearInstancePool(); - // Invalidate objects in StockPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - StockPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CombinationPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CombinationPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CombinationPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CombinationPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Combination object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CombinationPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CombinationPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CombinationPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CombinationPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CombinationPeer::DATABASE_NAME)->getTable(CombinationPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCombinationPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCombinationPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CombinationTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CombinationPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Combination or Criteria object. - * - * @param mixed $values Criteria or Combination object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Combination object - } - - if ($criteria->containsKey(CombinationPeer::ID) && $criteria->keyContainsValue(CombinationPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CombinationPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CombinationPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Combination or Criteria object. - * - * @param mixed $values Criteria or Combination object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CombinationPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CombinationPeer::ID); - $value = $criteria->remove(CombinationPeer::ID); - if ($value) { - $selectCriteria->add(CombinationPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CombinationPeer::TABLE_NAME); - } - - } else { // $values is Combination object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CombinationPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the combination table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CombinationPeer::TABLE_NAME, $con, CombinationPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CombinationPeer::clearInstancePool(); - CombinationPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Combination or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Combination object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CombinationPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Combination) { // it's a model object - // invalidate the cache for this single object - CombinationPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - $criteria->add(CombinationPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CombinationPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CombinationPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CombinationPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Combination object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Combination $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CombinationPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CombinationPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CombinationPeer::DATABASE_NAME, CombinationPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Combination - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CombinationPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - $criteria->add(CombinationPeer::ID, $pk); - - $v = CombinationPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Combination[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CombinationPeer::DATABASE_NAME); - $criteria->add(CombinationPeer::ID, $pks, Criteria::IN); - $objs = CombinationPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCombinationPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCombinationPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCombinationQuery.php b/core/lib/Thelia/Model/om/BaseCombinationQuery.php deleted file mode 100755 index 325af53bf..000000000 --- a/core/lib/Thelia/Model/om/BaseCombinationQuery.php +++ /dev/null @@ -1,637 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Combination|Combination[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CombinationPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CombinationPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Combination A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Combination A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `ref`, `created_at`, `updated_at` FROM `combination` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Combination(); - $obj->hydrate($row); - CombinationPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Combination|Combination[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Combination[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CombinationPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CombinationPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CombinationPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CombinationPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the ref column - * - * Example usage: - * - * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue' - * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%' - * - * - * @param string $ref The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterByRef($ref = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($ref)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $ref)) { - $ref = str_replace('*', '%', $ref); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CombinationPeer::REF, $ref, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CombinationPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related AttributeCombination object - * - * @param AttributeCombination|PropelObjectCollection $attributeCombination the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAttributeCombination($attributeCombination, $comparison = null) - { - if ($attributeCombination instanceof AttributeCombination) { - return $this - ->addUsingAlias(CombinationPeer::ID, $attributeCombination->getCombinationId(), $comparison); - } elseif ($attributeCombination instanceof PropelObjectCollection) { - return $this - ->useAttributeCombinationQuery() - ->filterByPrimaryKeys($attributeCombination->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAttributeCombination() only accepts arguments of type AttributeCombination or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AttributeCombination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CombinationQuery The current query, for fluid interface - */ - public function joinAttributeCombination($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AttributeCombination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AttributeCombination'); - } - - return $this; - } - - /** - * Use the AttributeCombination relation AttributeCombination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AttributeCombinationQuery A secondary query class using the current class as primary query - */ - public function useAttributeCombinationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAttributeCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AttributeCombination', '\Thelia\Model\AttributeCombinationQuery'); - } - - /** - * Filter the query by a related Stock object - * - * @param Stock|PropelObjectCollection $stock the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CombinationQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByStock($stock, $comparison = null) - { - if ($stock instanceof Stock) { - return $this - ->addUsingAlias(CombinationPeer::ID, $stock->getCombinationId(), $comparison); - } elseif ($stock instanceof PropelObjectCollection) { - return $this - ->useStockQuery() - ->filterByPrimaryKeys($stock->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Stock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CombinationQuery The current query, for fluid interface - */ - public function joinStock($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Stock'); - } - - return $this; - } - - /** - * Use the Stock relation Stock object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query - */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); - } - - /** - * Exclude object from result - * - * @param Combination $combination Object to remove from the list of results - * - * @return CombinationQuery The current query, for fluid interface - */ - public function prune($combination = null) - { - if ($combination) { - $this->addUsingAlias(CombinationPeer::ID, $combination->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CombinationQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CombinationPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CombinationQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CombinationPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CombinationQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CombinationPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CombinationQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CombinationPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CombinationQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CombinationPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CombinationQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CombinationPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseConfig.php b/core/lib/Thelia/Model/om/BaseConfig.php deleted file mode 100755 index 9a9e3b851..000000000 --- a/core/lib/Thelia/Model/om/BaseConfig.php +++ /dev/null @@ -1,1757 +0,0 @@ -secured = 1; - $this->hidden = 1; - } - - /** - * Initializes internal state of BaseConfig object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get the [value] column value. - * - * @return string - */ - public function getValue() - { - return $this->value; - } - - /** - * Get the [secured] column value. - * - * @return int - */ - public function getSecured() - { - return $this->secured; - } - - /** - * Get the [hidden] column value. - * - * @return int - */ - public function getHidden() - { - return $this->hidden; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Config The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ConfigPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return Config The current object (for fluent API support) - */ - public function setName($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = ConfigPeer::NAME; - } - - - return $this; - } // setName() - - /** - * Set the value of [value] column. - * - * @param string $v new value - * @return Config The current object (for fluent API support) - */ - public function setValue($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = ConfigPeer::VALUE; - } - - - return $this; - } // setValue() - - /** - * Set the value of [secured] column. - * - * @param int $v new value - * @return Config The current object (for fluent API support) - */ - public function setSecured($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->secured !== $v) { - $this->secured = $v; - $this->modifiedColumns[] = ConfigPeer::SECURED; - } - - - return $this; - } // setSecured() - - /** - * Set the value of [hidden] column. - * - * @param int $v new value - * @return Config The current object (for fluent API support) - */ - public function setHidden($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->hidden !== $v) { - $this->hidden = $v; - $this->modifiedColumns[] = ConfigPeer::HIDDEN; - } - - - return $this; - } // setHidden() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Config The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ConfigPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Config The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ConfigPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->secured !== 1) { - return false; - } - - if ($this->hidden !== 1) { - return false; - } - - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->value = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->secured = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->hidden = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = ConfigPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Config object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ConfigPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collConfigI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ConfigQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ConfigPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ConfigPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ConfigPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ConfigPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->configI18nsScheduledForDeletion !== null) { - if (!$this->configI18nsScheduledForDeletion->isEmpty()) { - ConfigI18nQuery::create() - ->filterByPrimaryKeys($this->configI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->configI18nsScheduledForDeletion = null; - } - } - - if ($this->collConfigI18ns !== null) { - foreach ($this->collConfigI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ConfigPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ConfigPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ConfigPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`name`'; - } - if ($this->isColumnModified(ConfigPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; - } - if ($this->isColumnModified(ConfigPeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`secured`'; - } - if ($this->isColumnModified(ConfigPeer::HIDDEN)) { - $modifiedColumns[':p' . $index++] = '`hidden`'; - } - if ($this->isColumnModified(ConfigPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `config` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`name`': - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); - break; - case '`value`': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); - break; - case '`secured`': - $stmt->bindValue($identifier, $this->secured, PDO::PARAM_INT); - break; - case '`hidden`': - $stmt->bindValue($identifier, $this->hidden, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = ConfigPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collConfigI18ns !== null) { - foreach ($this->collConfigI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getName(); - break; - case 2: - return $this->getValue(); - break; - case 3: - return $this->getSecured(); - break; - case 4: - return $this->getHidden(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Config'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Config'][$this->getPrimaryKey()] = true; - $keys = ConfigPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getName(), - $keys[2] => $this->getValue(), - $keys[3] => $this->getSecured(), - $keys[4] => $this->getHidden(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collConfigI18ns) { - $result['ConfigI18ns'] = $this->collConfigI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ConfigPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setName($value); - break; - case 2: - $this->setValue($value); - break; - case 3: - $this->setSecured($value); - break; - case 4: - $this->setHidden($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ConfigPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setValue($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setSecured($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setHidden($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - - if ($this->isColumnModified(ConfigPeer::ID)) $criteria->add(ConfigPeer::ID, $this->id); - if ($this->isColumnModified(ConfigPeer::NAME)) $criteria->add(ConfigPeer::NAME, $this->name); - if ($this->isColumnModified(ConfigPeer::VALUE)) $criteria->add(ConfigPeer::VALUE, $this->value); - if ($this->isColumnModified(ConfigPeer::SECURED)) $criteria->add(ConfigPeer::SECURED, $this->secured); - if ($this->isColumnModified(ConfigPeer::HIDDEN)) $criteria->add(ConfigPeer::HIDDEN, $this->hidden); - if ($this->isColumnModified(ConfigPeer::CREATED_AT)) $criteria->add(ConfigPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ConfigPeer::UPDATED_AT)) $criteria->add(ConfigPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - $criteria->add(ConfigPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Config (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setName($this->getName()); - $copyObj->setValue($this->getValue()); - $copyObj->setSecured($this->getSecured()); - $copyObj->setHidden($this->getHidden()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getConfigI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addConfigI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Config Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ConfigPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ConfigPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('ConfigI18n' == $relationName) { - $this->initConfigI18ns(); - } - } - - /** - * Clears out the collConfigI18ns 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 Config The current object (for fluent API support) - * @see addConfigI18ns() - */ - public function clearConfigI18ns() - { - $this->collConfigI18ns = null; // important to set this to null since that means it is uninitialized - $this->collConfigI18nsPartial = null; - - return $this; - } - - /** - * reset is the collConfigI18ns collection loaded partially - * - * @return void - */ - public function resetPartialConfigI18ns($v = true) - { - $this->collConfigI18nsPartial = $v; - } - - /** - * Initializes the collConfigI18ns collection. - * - * By default this just sets the collConfigI18ns collection to an empty array (like clearcollConfigI18ns()); - * 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 initConfigI18ns($overrideExisting = true) - { - if (null !== $this->collConfigI18ns && !$overrideExisting) { - return; - } - $this->collConfigI18ns = new PropelObjectCollection(); - $this->collConfigI18ns->setModel('ConfigI18n'); - } - - /** - * Gets an array of ConfigI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Config is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ConfigI18n[] List of ConfigI18n objects - * @throws PropelException - */ - public function getConfigI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collConfigI18nsPartial && !$this->isNew(); - if (null === $this->collConfigI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collConfigI18ns) { - // return empty collection - $this->initConfigI18ns(); - } else { - $collConfigI18ns = ConfigI18nQuery::create(null, $criteria) - ->filterByConfig($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collConfigI18nsPartial && count($collConfigI18ns)) { - $this->initConfigI18ns(false); - - foreach($collConfigI18ns as $obj) { - if (false == $this->collConfigI18ns->contains($obj)) { - $this->collConfigI18ns->append($obj); - } - } - - $this->collConfigI18nsPartial = true; - } - - $collConfigI18ns->getInternalIterator()->rewind(); - return $collConfigI18ns; - } - - if($partial && $this->collConfigI18ns) { - foreach($this->collConfigI18ns as $obj) { - if($obj->isNew()) { - $collConfigI18ns[] = $obj; - } - } - } - - $this->collConfigI18ns = $collConfigI18ns; - $this->collConfigI18nsPartial = false; - } - } - - return $this->collConfigI18ns; - } - - /** - * Sets a collection of ConfigI18n 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 $configI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Config The current object (for fluent API support) - */ - public function setConfigI18ns(PropelCollection $configI18ns, PropelPDO $con = null) - { - $configI18nsToDelete = $this->getConfigI18ns(new Criteria(), $con)->diff($configI18ns); - - $this->configI18nsScheduledForDeletion = unserialize(serialize($configI18nsToDelete)); - - foreach ($configI18nsToDelete as $configI18nRemoved) { - $configI18nRemoved->setConfig(null); - } - - $this->collConfigI18ns = null; - foreach ($configI18ns as $configI18n) { - $this->addConfigI18n($configI18n); - } - - $this->collConfigI18ns = $configI18ns; - $this->collConfigI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ConfigI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ConfigI18n objects. - * @throws PropelException - */ - public function countConfigI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collConfigI18nsPartial && !$this->isNew(); - if (null === $this->collConfigI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collConfigI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getConfigI18ns()); - } - $query = ConfigI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByConfig($this) - ->count($con); - } - - return count($this->collConfigI18ns); - } - - /** - * Method called to associate a ConfigI18n object to this object - * through the ConfigI18n foreign key attribute. - * - * @param ConfigI18n $l ConfigI18n - * @return Config The current object (for fluent API support) - */ - public function addConfigI18n(ConfigI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collConfigI18ns === null) { - $this->initConfigI18ns(); - $this->collConfigI18nsPartial = true; - } - if (!in_array($l, $this->collConfigI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddConfigI18n($l); - } - - return $this; - } - - /** - * @param ConfigI18n $configI18n The configI18n object to add. - */ - protected function doAddConfigI18n($configI18n) - { - $this->collConfigI18ns[]= $configI18n; - $configI18n->setConfig($this); - } - - /** - * @param ConfigI18n $configI18n The configI18n object to remove. - * @return Config The current object (for fluent API support) - */ - public function removeConfigI18n($configI18n) - { - if ($this->getConfigI18ns()->contains($configI18n)) { - $this->collConfigI18ns->remove($this->collConfigI18ns->search($configI18n)); - if (null === $this->configI18nsScheduledForDeletion) { - $this->configI18nsScheduledForDeletion = clone $this->collConfigI18ns; - $this->configI18nsScheduledForDeletion->clear(); - } - $this->configI18nsScheduledForDeletion[]= clone $configI18n; - $configI18n->setConfig(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->value = null; - $this->secured = null; - $this->hidden = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collConfigI18ns) { - foreach ($this->collConfigI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collConfigI18ns instanceof PropelCollection) { - $this->collConfigI18ns->clearIterator(); - } - $this->collConfigI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ConfigPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Config The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ConfigPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Config The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ConfigI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collConfigI18ns) { - foreach ($this->collConfigI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ConfigI18n(); - $translation->setLocale($locale); - } else { - $translation = ConfigI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addConfigI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Config The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ConfigI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collConfigI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collConfigI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ConfigI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseConfigI18n.php b/core/lib/Thelia/Model/om/BaseConfigI18n.php deleted file mode 100755 index 945a9911d..000000000 --- a/core/lib/Thelia/Model/om/BaseConfigI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseConfigI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ConfigI18nPeer::ID; - } - - if ($this->aConfig !== null && $this->aConfig->getId() !== $v) { - $this->aConfig = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ConfigI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ConfigI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ConfigI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ConfigI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ConfigI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ConfigI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ConfigI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ConfigI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aConfig !== null && $this->id !== $this->aConfig->getId()) { - $this->aConfig = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::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 = ConfigI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aConfig = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ConfigI18nQuery::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(ConfigI18nPeer::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); - ConfigI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aConfig !== null) { - if ($this->aConfig->isModified() || $this->aConfig->isNew()) { - $affectedRows += $this->aConfig->save($con); - } - $this->setConfig($this->aConfig); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ConfigI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ConfigI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ConfigI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ConfigI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ConfigI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ConfigI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `config_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aConfig !== null) { - if (!$this->aConfig->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aConfig->getValidationFailures()); - } - } - - - if (($retval = ConfigI18nPeer::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 = ConfigI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ConfigI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ConfigI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ConfigI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aConfig) { - $result['Config'] = $this->aConfig->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ConfigI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ConfigI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ConfigI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ConfigI18nPeer::ID)) $criteria->add(ConfigI18nPeer::ID, $this->id); - if ($this->isColumnModified(ConfigI18nPeer::LOCALE)) $criteria->add(ConfigI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ConfigI18nPeer::TITLE)) $criteria->add(ConfigI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ConfigI18nPeer::DESCRIPTION)) $criteria->add(ConfigI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ConfigI18nPeer::CHAPO)) $criteria->add(ConfigI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ConfigI18nPeer::POSTSCRIPTUM)) $criteria->add(ConfigI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ConfigI18nPeer::DATABASE_NAME); - $criteria->add(ConfigI18nPeer::ID, $this->id); - $criteria->add(ConfigI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ConfigI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ConfigI18n 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 ConfigI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ConfigI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Config object. - * - * @param Config $v - * @return ConfigI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setConfig(Config $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aConfig = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Config object, it will not be re-added. - if ($v !== null) { - $v->addConfigI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Config object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Config The associated Config object. - * @throws PropelException - */ - public function getConfig(PropelPDO $con = null, $doQuery = true) - { - if ($this->aConfig === null && ($this->id !== null) && $doQuery) { - $this->aConfig = ConfigQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aConfig->addConfigI18ns($this); - */ - } - - return $this->aConfig; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aConfig instanceof Persistent) { - $this->aConfig->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aConfig = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ConfigI18nPeer::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/BaseConfigI18nPeer.php b/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php deleted file mode 100755 index b1865513f..000000000 --- a/core/lib/Thelia/Model/om/BaseConfigI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ConfigI18nPeer::ID, ConfigI18nPeer::LOCALE, ConfigI18nPeer::TITLE, ConfigI18nPeer::DESCRIPTION, ConfigI18nPeer::CHAPO, ConfigI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ConfigI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ConfigI18nPeer::ID => 0, ConfigI18nPeer::LOCALE => 1, ConfigI18nPeer::TITLE => 2, ConfigI18nPeer::DESCRIPTION => 3, ConfigI18nPeer::CHAPO => 4, ConfigI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ConfigI18nPeer::getFieldNames($toType); - $key = isset(ConfigI18nPeer::$fieldKeys[$fromType][$name]) ? ConfigI18nPeer::$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(ConfigI18nPeer::$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, ConfigI18nPeer::$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 ConfigI18nPeer::$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. ConfigI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ConfigI18nPeer::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(ConfigI18nPeer::ID); - $criteria->addSelectColumn(ConfigI18nPeer::LOCALE); - $criteria->addSelectColumn(ConfigI18nPeer::TITLE); - $criteria->addSelectColumn(ConfigI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ConfigI18nPeer::CHAPO); - $criteria->addSelectColumn(ConfigI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ConfigI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ConfigI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ConfigI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::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 ConfigI18n - * @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 = ConfigI18nPeer::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 ConfigI18nPeer::populateObjects(ConfigI18nPeer::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 directly (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(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ConfigI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ConfigI18nPeer::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 ConfigI18n $obj A ConfigI18n 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->getLocale())); - } // if key === null - ConfigI18nPeer::$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 ConfigI18n 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 ConfigI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ConfigI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ConfigI18nPeer::$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 ConfigI18n 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(ConfigI18nPeer::$instances[$key])) { - return ConfigI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ConfigI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ConfigI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to config_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ConfigI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ConfigI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ConfigI18nPeer::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; - ConfigI18nPeer::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 (ConfigI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ConfigI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ConfigI18nPeer::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 + ConfigI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ConfigI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ConfigI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Config table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinConfig(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ConfigI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ConfigI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ConfigI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ConfigI18nPeer::ID, ConfigPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ConfigI18n objects pre-filled with their Config objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ConfigI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinConfig(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ConfigI18nPeer::DATABASE_NAME); - } - - ConfigI18nPeer::addSelectColumns($criteria); - $startcol = ConfigI18nPeer::NUM_HYDRATE_COLUMNS; - ConfigPeer::addSelectColumns($criteria); - - $criteria->addJoin(ConfigI18nPeer::ID, ConfigPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ConfigI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ConfigI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ConfigI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ConfigI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ConfigPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ConfigPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ConfigPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ConfigI18n) to $obj2 (Config) - $obj2->addConfigI18n($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(ConfigI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ConfigI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ConfigI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ConfigI18nPeer::ID, ConfigPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ConfigI18n 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 ConfigI18n 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(ConfigI18nPeer::DATABASE_NAME); - } - - ConfigI18nPeer::addSelectColumns($criteria); - $startcol2 = ConfigI18nPeer::NUM_HYDRATE_COLUMNS; - - ConfigPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ConfigPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ConfigI18nPeer::ID, ConfigPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ConfigI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ConfigI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ConfigI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ConfigI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Config rows - - $key2 = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ConfigPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ConfigPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ConfigPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ConfigI18n) to the collection in $obj2 (Config) - $obj2->addConfigI18n($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(ConfigI18nPeer::DATABASE_NAME)->getTable(ConfigI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseConfigI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseConfigI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ConfigI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ConfigI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ConfigI18n or Criteria object. - * - * @param mixed $values Criteria or ConfigI18n 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(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ConfigI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ConfigI18nPeer::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 ConfigI18n or Criteria object. - * - * @param mixed $values Criteria or ConfigI18n 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(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ConfigI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ConfigI18nPeer::ID); - $value = $criteria->remove(ConfigI18nPeer::ID); - if ($value) { - $selectCriteria->add(ConfigI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ConfigI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ConfigI18nPeer::LOCALE); - $value = $criteria->remove(ConfigI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ConfigI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ConfigI18nPeer::TABLE_NAME); - } - - } else { // $values is ConfigI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ConfigI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the config_i18n 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(ConfigI18nPeer::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(ConfigI18nPeer::TABLE_NAME, $con, ConfigI18nPeer::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). - ConfigI18nPeer::clearInstancePool(); - ConfigI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ConfigI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ConfigI18n 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(ConfigI18nPeer::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. - ConfigI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ConfigI18n) { // it's a model object - // invalidate the cache for this single object - ConfigI18nPeer::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(ConfigI18nPeer::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(ConfigI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ConfigI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ConfigI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ConfigI18nPeer::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); - ConfigI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ConfigI18n 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 ConfigI18n $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(ConfigI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ConfigI18nPeer::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(ConfigI18nPeer::DATABASE_NAME, ConfigI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ConfigI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ConfigI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ConfigI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ConfigI18nPeer::DATABASE_NAME); - $criteria->add(ConfigI18nPeer::ID, $id); - $criteria->add(ConfigI18nPeer::LOCALE, $locale); - $v = ConfigI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseConfigI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseConfigI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php b/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php deleted file mode 100755 index f53cc2de2..000000000 --- a/core/lib/Thelia/Model/om/BaseConfigI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ConfigI18n|ConfigI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ConfigI18nPeer::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(ConfigI18nPeer::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 ConfigI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `config_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ConfigI18n(); - $obj->hydrate($row); - ConfigI18nPeer::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 ConfigI18n|ConfigI18n[]|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|ConfigI18n[]|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 ConfigI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ConfigI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ConfigI18nPeer::LOCALE, $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 ConfigI18nQuery 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(ConfigI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ConfigI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByConfig() - * - * @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 ConfigI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ConfigI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ConfigI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ConfigI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Config object - * - * @param Config|PropelObjectCollection $config The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByConfig($config, $comparison = null) - { - if ($config instanceof Config) { - return $this - ->addUsingAlias(ConfigI18nPeer::ID, $config->getId(), $comparison); - } elseif ($config instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ConfigI18nPeer::ID, $config->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByConfig() only accepts arguments of type Config or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Config relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function joinConfig($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Config'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Config'); - } - - return $this; - } - - /** - * Use the Config relation Config object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ConfigQuery A secondary query class using the current class as primary query - */ - public function useConfigQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinConfig($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Config', '\Thelia\Model\ConfigQuery'); - } - - /** - * Exclude object from result - * - * @param ConfigI18n $configI18n Object to remove from the list of results - * - * @return ConfigI18nQuery The current query, for fluid interface - */ - public function prune($configI18n = null) - { - if ($configI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ConfigI18nPeer::ID), $configI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ConfigI18nPeer::LOCALE), $configI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseConfigPeer.php b/core/lib/Thelia/Model/om/BaseConfigPeer.php deleted file mode 100755 index 0981b9523..000000000 --- a/core/lib/Thelia/Model/om/BaseConfigPeer.php +++ /dev/null @@ -1,811 +0,0 @@ - array ('Id', 'Name', 'Value', 'Secured', 'Hidden', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'value', 'secured', 'hidden', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ConfigPeer::ID, ConfigPeer::NAME, ConfigPeer::VALUE, ConfigPeer::SECURED, ConfigPeer::HIDDEN, ConfigPeer::CREATED_AT, ConfigPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'VALUE', 'SECURED', 'HIDDEN', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'value', 'secured', 'hidden', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ConfigPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Value' => 2, 'Secured' => 3, 'Hidden' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (ConfigPeer::ID => 0, ConfigPeer::NAME => 1, ConfigPeer::VALUE => 2, ConfigPeer::SECURED => 3, ConfigPeer::HIDDEN => 4, ConfigPeer::CREATED_AT => 5, ConfigPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'VALUE' => 2, 'SECURED' => 3, 'HIDDEN' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'value' => 2, 'secured' => 3, 'hidden' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ConfigPeer::getFieldNames($toType); - $key = isset(ConfigPeer::$fieldKeys[$fromType][$name]) ? ConfigPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ConfigPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ConfigPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ConfigPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ConfigPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ConfigPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ConfigPeer::ID); - $criteria->addSelectColumn(ConfigPeer::NAME); - $criteria->addSelectColumn(ConfigPeer::VALUE); - $criteria->addSelectColumn(ConfigPeer::SECURED); - $criteria->addSelectColumn(ConfigPeer::HIDDEN); - $criteria->addSelectColumn(ConfigPeer::CREATED_AT); - $criteria->addSelectColumn(ConfigPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.name'); - $criteria->addSelectColumn($alias . '.value'); - $criteria->addSelectColumn($alias . '.secured'); - $criteria->addSelectColumn($alias . '.hidden'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ConfigPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ConfigPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ConfigPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Config - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ConfigPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ConfigPeer::populateObjects(ConfigPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ConfigPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ConfigPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Config $obj A Config object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ConfigPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Config object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Config) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Config object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ConfigPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Config Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ConfigPeer::$instances[$key])) { - return ConfigPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ConfigPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ConfigPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to config - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ConfigI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ConfigI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ConfigPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ConfigPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ConfigPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Config object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ConfigPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ConfigPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ConfigPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ConfigPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ConfigPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME)->getTable(ConfigPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseConfigPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseConfigPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ConfigTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ConfigPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Config or Criteria object. - * - * @param mixed $values Criteria or Config object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Config object - } - - if ($criteria->containsKey(ConfigPeer::ID) && $criteria->keyContainsValue(ConfigPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConfigPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ConfigPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Config or Criteria object. - * - * @param mixed $values Criteria or Config object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ConfigPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ConfigPeer::ID); - $value = $criteria->remove(ConfigPeer::ID); - if ($value) { - $selectCriteria->add(ConfigPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ConfigPeer::TABLE_NAME); - } - - } else { // $values is Config object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ConfigPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the config table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ConfigPeer::TABLE_NAME, $con, ConfigPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ConfigPeer::clearInstancePool(); - ConfigPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Config or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Config object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ConfigPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Config) { // it's a model object - // invalidate the cache for this single object - ConfigPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - $criteria->add(ConfigPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ConfigPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ConfigPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ConfigPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Config object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Config $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ConfigPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ConfigPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ConfigPeer::DATABASE_NAME, ConfigPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Config - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ConfigPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - $criteria->add(ConfigPeer::ID, $pk); - - $v = ConfigPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Config[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ConfigPeer::DATABASE_NAME); - $criteria->add(ConfigPeer::ID, $pks, Criteria::IN); - $objs = ConfigPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseConfigPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseConfigPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseConfigQuery.php b/core/lib/Thelia/Model/om/BaseConfigQuery.php deleted file mode 100755 index 808e6e5bd..000000000 --- a/core/lib/Thelia/Model/om/BaseConfigQuery.php +++ /dev/null @@ -1,740 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Config|Config[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ConfigPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ConfigPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Config A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Config A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `name`, `value`, `secured`, `hidden`, `created_at`, `updated_at` FROM `config` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Config(); - $obj->hydrate($row); - ConfigPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Config|Config[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Config[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ConfigPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ConfigPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ConfigPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ConfigPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the name column - * - * Example usage: - * - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' - * - * - * @param string $name The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByName($name = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($name)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $name)) { - $name = str_replace('*', '%', $name); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigPeer::NAME, $name, $comparison); - } - - /** - * Filter the query on the value column - * - * Example usage: - * - * $query->filterByValue('fooValue'); // WHERE value = 'fooValue' - * $query->filterByValue('%fooValue%'); // WHERE value LIKE '%fooValue%' - * - * - * @param string $value The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByValue($value = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($value)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $value)) { - $value = str_replace('*', '%', $value); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ConfigPeer::VALUE, $value, $comparison); - } - - /** - * Filter the query on the 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 - * $query->filterBySecured(array('max' => 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 ConfigQuery 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(ConfigPeer::SECURED, $secured['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($secured['max'])) { - $this->addUsingAlias(ConfigPeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigPeer::SECURED, $secured, $comparison); - } - - /** - * Filter the query on the hidden column - * - * Example usage: - * - * $query->filterByHidden(1234); // WHERE hidden = 1234 - * $query->filterByHidden(array(12, 34)); // WHERE hidden IN (12, 34) - * $query->filterByHidden(array('min' => 12)); // WHERE hidden >= 12 - * $query->filterByHidden(array('max' => 12)); // WHERE hidden <= 12 - * - * - * @param mixed $hidden The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByHidden($hidden = null, $comparison = null) - { - if (is_array($hidden)) { - $useMinMax = false; - if (isset($hidden['min'])) { - $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($hidden['max'])) { - $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigPeer::HIDDEN, $hidden, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ConfigPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related ConfigI18n object - * - * @param ConfigI18n|PropelObjectCollection $configI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ConfigQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByConfigI18n($configI18n, $comparison = null) - { - if ($configI18n instanceof ConfigI18n) { - return $this - ->addUsingAlias(ConfigPeer::ID, $configI18n->getId(), $comparison); - } elseif ($configI18n instanceof PropelObjectCollection) { - return $this - ->useConfigI18nQuery() - ->filterByPrimaryKeys($configI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByConfigI18n() only accepts arguments of type ConfigI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ConfigI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ConfigQuery The current query, for fluid interface - */ - public function joinConfigI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ConfigI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ConfigI18n'); - } - - return $this; - } - - /** - * Use the ConfigI18n relation ConfigI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ConfigI18nQuery A secondary query class using the current class as primary query - */ - public function useConfigI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinConfigI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', '\Thelia\Model\ConfigI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Config $config Object to remove from the list of results - * - * @return ConfigQuery The current query, for fluid interface - */ - public function prune($config = null) - { - if ($config) { - $this->addUsingAlias(ConfigPeer::ID, $config->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ConfigQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ConfigPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ConfigQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ConfigPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ConfigQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ConfigPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ConfigQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ConfigPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ConfigQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ConfigPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ConfigQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ConfigPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ConfigQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; - - return $this - ->joinConfigI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ConfigQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ConfigI18n'); - $this->with['ConfigI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ConfigI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ConfigI18n', 'Thelia\Model\ConfigI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseContent.php b/core/lib/Thelia/Model/om/BaseContent.php deleted file mode 100755 index a7fbcb3a4..000000000 --- a/core/lib/Thelia/Model/om/BaseContent.php +++ /dev/null @@ -1,4358 +0,0 @@ -version = 0; - } - - /** - * Initializes internal state of BaseContent 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 Content The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ContentPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [visible] column. - * - * @param int $v new value - * @return Content The current object (for fluent API support) - */ - public function setVisible($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->visible !== $v) { - $this->visible = $v; - $this->modifiedColumns[] = ContentPeer::VISIBLE; - } - - - return $this; - } // setVisible() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Content The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ContentPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Content The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ContentPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Content The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ContentPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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. - * - * 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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = ContentPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Content object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ContentPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collContentAssocs = null; - - $this->collImages = null; - - $this->collDocuments = null; - - $this->collRewritings = null; - - $this->collContentFolders = null; - - $this->collContentI18ns = null; - - $this->collContentVersions = null; - - $this->collFolders = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ContentQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - // 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 - if (!$this->isColumnModified(ContentPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ContentPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ContentPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - // versionable behavior - if (isset($createVersion)) { - $this->addVersion($con); - } - ContentPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->foldersScheduledForDeletion !== null) { - if (!$this->foldersScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->foldersScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - ContentFolderQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->foldersScheduledForDeletion = null; - } - - foreach ($this->getFolders() as $folder) { - if ($folder->isModified()) { - $folder->save($con); - } - } - } elseif ($this->collFolders) { - foreach ($this->collFolders as $folder) { - if ($folder->isModified()) { - $folder->save($con); - } - } - } - - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - foreach ($this->imagesScheduledForDeletion as $image) { - // need to save related object because we set the relation to null - $image->save($con); - } - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - foreach ($this->rewritingsScheduledForDeletion as $rewriting) { - // need to save related object because we set the relation to null - $rewriting->save($con); - } - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->contentFoldersScheduledForDeletion !== null) { - if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() - ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentFoldersScheduledForDeletion = null; - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->contentI18nsScheduledForDeletion !== null) { - if (!$this->contentI18nsScheduledForDeletion->isEmpty()) { - ContentI18nQuery::create() - ->filterByPrimaryKeys($this->contentI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentI18nsScheduledForDeletion = null; - } - } - - if ($this->collContentI18ns !== null) { - foreach ($this->collContentI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - 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() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ContentPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ContentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ContentPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; - } - if ($this->isColumnModified(ContentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(ContentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ContentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - 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)', - 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); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = ContentPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentI18ns !== null) { - foreach ($this->collContentI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentVersions !== null) { - foreach ($this->collContentVersions as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getVisible(); - break; - case 2: - return $this->getPosition(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - 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['Content'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Content'][$this->getPrimaryKey()] = true; - $keys = ContentPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getVisible(), - $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - $keys[5] => $this->getVersion(), - $keys[6] => $this->getVersionCreatedAt(), - $keys[7] => $this->getVersionCreatedBy(), - ); - if ($includeForeignObjects) { - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collContentFolders) { - $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - 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; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setVisible($value); - break; - case 2: - $this->setPosition($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - 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 = ContentPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - 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(ContentPeer::DATABASE_NAME); - - if ($this->isColumnModified(ContentPeer::ID)) $criteria->add(ContentPeer::ID, $this->id); - if ($this->isColumnModified(ContentPeer::VISIBLE)) $criteria->add(ContentPeer::VISIBLE, $this->visible); - if ($this->isColumnModified(ContentPeer::POSITION)) $criteria->add(ContentPeer::POSITION, $this->position); - if ($this->isColumnModified(ContentPeer::CREATED_AT)) $criteria->add(ContentPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ContentPeer::UPDATED_AT)) $criteria->add(ContentPeer::UPDATED_AT, $this->updated_at); - 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; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ContentPeer::DATABASE_NAME); - $criteria->add(ContentPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Content (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setVisible($this->getVisible()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - $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; - - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - - foreach ($this->getContentFolders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentFolder($relObj->copy($deepCopy)); - } - } - - foreach ($this->getContentI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentI18n($relObj->copy($deepCopy)); - } - } - - 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) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Content Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ContentPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ContentPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } - if ('Image' == $relationName) { - $this->initImages(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('Rewriting' == $relationName) { - $this->initRewritings(); - } - if ('ContentFolder' == $relationName) { - $this->initContentFolders(); - } - if ('ContentI18n' == $relationName) { - $this->initContentI18ns(); - } - if ('ContentVersion' == $relationName) { - $this->initContentVersions(); - } - } - - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Content The current object (for fluent API support) - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; - } - - /** - * reset is the collContentAssocs collection loaded partially - * - * @return void - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); - } - - /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - return $collContentAssocs; - } - - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentAssocs A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setContent(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. - * - * @param ContentAssoc $l ContentAssoc - * @return Content The current object (for fluent API support) - */ - public function addContentAssoc(ContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setContent($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Content The current object (for fluent API support) - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; - } - - /** - * reset is the collImages collection loaded partially - * - * @return void - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); - } - - /** - * Gets an array of Image objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Image[] List of Image objects - * @throws PropelException - */ - public function getImages($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ImageQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - return $collImages; - } - - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $images A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setImages(PropelCollection $images, PropelPDO $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setContent(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. - * - * @param Image $l Image - * @return Content The current object (for fluent API support) - */ - public function addImage(Image $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setContent($this); - } - - /** - * @param Image $image The image object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Content The current object (for fluent API support) - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setContent(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Content The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setContent($this); - } - - /** - * @param Document $document The document object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Content The current object (for fluent API support) - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; - } - - /** - * reset is the collRewritings collection loaded partially - * - * @return void - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); - } - - /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = RewritingQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - return $collRewritings; - } - - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $rewritings A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setContent(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. - * - * @param Rewriting $l Rewriting - * @return Content The current object (for fluent API support) - */ - public function addRewriting(Rewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setContent($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getRewritings($query, $con); - } - - /** - * Clears out the collContentFolders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Content The current object (for fluent API support) - * @see addContentFolders() - */ - public function clearContentFolders() - { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - - return $this; - } - - /** - * reset is the collContentFolders collection loaded partially - * - * @return void - */ - public function resetPartialContentFolders($v = true) - { - $this->collContentFoldersPartial = $v; - } - - /** - * Initializes the collContentFolders collection. - * - * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentFolders($overrideExisting = true) - { - if (null !== $this->collContentFolders && !$overrideExisting) { - return; - } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); - } - - /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Content is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - * @throws PropelException - */ - public function getContentFolders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - // return empty collection - $this->initContentFolders(); - } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); - - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); - } - } - - $this->collContentFoldersPartial = true; - } - - $collContentFolders->getInternalIterator()->rewind(); - return $collContentFolders; - } - - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { - $collContentFolders[] = $obj; - } - } - } - - $this->collContentFolders = $collContentFolders; - $this->collContentFoldersPartial = false; - } - } - - return $this->collContentFolders; - } - - /** - * Sets a collection of ContentFolder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentFolders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) - { - $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - - $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); - - foreach ($contentFoldersToDelete as $contentFolderRemoved) { - $contentFolderRemoved->setContent(null); - } - - $this->collContentFolders = null; - foreach ($contentFolders as $contentFolder) { - $this->addContentFolder($contentFolder); - } - - $this->collContentFolders = $contentFolders; - $this->collContentFoldersPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentFolder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentFolder objects. - * @throws PropelException - */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentFolders()); - } - $query = ContentFolderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentFolders); - } - - /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. - * - * @param ContentFolder $l ContentFolder - * @return Content The current object (for fluent API support) - */ - public function addContentFolder(ContentFolder $l) - { - if ($this->collContentFolders === null) { - $this->initContentFolders(); - $this->collContentFoldersPartial = true; - } - if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentFolder($l); - } - - return $this; - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to add. - */ - protected function doAddContentFolder($contentFolder) - { - $this->collContentFolders[]= $contentFolder; - $contentFolder->setContent($this); - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeContentFolder($contentFolder) - { - if ($this->getContentFolders()->contains($contentFolder)) { - $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); - if (null === $this->contentFoldersScheduledForDeletion) { - $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; - $this->contentFoldersScheduledForDeletion->clear(); - } - $this->contentFoldersScheduledForDeletion[]= clone $contentFolder; - $contentFolder->setContent(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Content is new, it will return - * an empty collection; or if this Content has previously - * been saved, it will retrieve related ContentFolders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Content. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - */ - public function getContentFoldersJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getContentFolders($query, $con); - } - - /** - * Clears out the collContentI18ns 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 Content The current object (for fluent API support) - * @see addContentI18ns() - */ - public function clearContentI18ns() - { - $this->collContentI18ns = null; // important to set this to null since that means it is uninitialized - $this->collContentI18nsPartial = null; - - return $this; - } - - /** - * reset is the collContentI18ns collection loaded partially - * - * @return void - */ - public function resetPartialContentI18ns($v = true) - { - $this->collContentI18nsPartial = $v; - } - - /** - * Initializes the collContentI18ns collection. - * - * By default this just sets the collContentI18ns collection to an empty array (like clearcollContentI18ns()); - * 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 initContentI18ns($overrideExisting = true) - { - if (null !== $this->collContentI18ns && !$overrideExisting) { - return; - } - $this->collContentI18ns = new PropelObjectCollection(); - $this->collContentI18ns->setModel('ContentI18n'); - } - - /** - * Gets an array of ContentI18n 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|ContentI18n[] List of ContentI18n objects - * @throws PropelException - */ - public function getContentI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentI18nsPartial && !$this->isNew(); - if (null === $this->collContentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentI18ns) { - // return empty collection - $this->initContentI18ns(); - } else { - $collContentI18ns = ContentI18nQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentI18nsPartial && count($collContentI18ns)) { - $this->initContentI18ns(false); - - foreach($collContentI18ns as $obj) { - if (false == $this->collContentI18ns->contains($obj)) { - $this->collContentI18ns->append($obj); - } - } - - $this->collContentI18nsPartial = true; - } - - $collContentI18ns->getInternalIterator()->rewind(); - return $collContentI18ns; - } - - if($partial && $this->collContentI18ns) { - foreach($this->collContentI18ns as $obj) { - if($obj->isNew()) { - $collContentI18ns[] = $obj; - } - } - } - - $this->collContentI18ns = $collContentI18ns; - $this->collContentI18nsPartial = false; - } - } - - return $this->collContentI18ns; - } - - /** - * Sets a collection of ContentI18n 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 $contentI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setContentI18ns(PropelCollection $contentI18ns, PropelPDO $con = null) - { - $contentI18nsToDelete = $this->getContentI18ns(new Criteria(), $con)->diff($contentI18ns); - - $this->contentI18nsScheduledForDeletion = unserialize(serialize($contentI18nsToDelete)); - - foreach ($contentI18nsToDelete as $contentI18nRemoved) { - $contentI18nRemoved->setContent(null); - } - - $this->collContentI18ns = null; - foreach ($contentI18ns as $contentI18n) { - $this->addContentI18n($contentI18n); - } - - $this->collContentI18ns = $contentI18ns; - $this->collContentI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentI18n objects. - * @throws PropelException - */ - public function countContentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentI18nsPartial && !$this->isNew(); - if (null === $this->collContentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentI18ns()); - } - $query = ContentI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentI18ns); - } - - /** - * Method called to associate a ContentI18n object to this object - * through the ContentI18n foreign key attribute. - * - * @param ContentI18n $l ContentI18n - * @return Content The current object (for fluent API support) - */ - public function addContentI18n(ContentI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collContentI18ns === null) { - $this->initContentI18ns(); - $this->collContentI18nsPartial = true; - } - if (!in_array($l, $this->collContentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentI18n($l); - } - - return $this; - } - - /** - * @param ContentI18n $contentI18n The contentI18n object to add. - */ - protected function doAddContentI18n($contentI18n) - { - $this->collContentI18ns[]= $contentI18n; - $contentI18n->setContent($this); - } - - /** - * @param ContentI18n $contentI18n The contentI18n object to remove. - * @return Content The current object (for fluent API support) - */ - public function removeContentI18n($contentI18n) - { - if ($this->getContentI18ns()->contains($contentI18n)) { - $this->collContentI18ns->remove($this->collContentI18ns->search($contentI18n)); - if (null === $this->contentI18nsScheduledForDeletion) { - $this->contentI18nsScheduledForDeletion = clone $this->collContentI18ns; - $this->contentI18nsScheduledForDeletion->clear(); - } - $this->contentI18nsScheduledForDeletion[]= clone $contentI18n; - $contentI18n->setContent(null); - } - - return $this; - } - - /** - * 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 Content The current object (for fluent API support) - * @see addContentVersions() - */ - public function clearContentVersions() - { - $this->collContentVersions = null; // important to set this to null since that means it is uninitialized - $this->collContentVersionsPartial = null; - - return $this; - } - - /** - * 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; - } - - $collContentVersions->getInternalIterator()->rewind(); - 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 - * @return Content The current object (for fluent API support) - */ - public function setContentVersions(PropelCollection $contentVersions, PropelPDO $con = null) - { - $contentVersionsToDelete = $this->getContentVersions(new Criteria(), $con)->diff($contentVersions); - - $this->contentVersionsScheduledForDeletion = unserialize(serialize($contentVersionsToDelete)); - - foreach ($contentVersionsToDelete as $contentVersionRemoved) { - $contentVersionRemoved->setContent(null); - } - - $this->collContentVersions = null; - foreach ($contentVersions as $contentVersion) { - $this->addContentVersion($contentVersion); - } - - $this->collContentVersions = $contentVersions; - $this->collContentVersionsPartial = false; - - return $this; - } - - /** - * 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; - } - - if($partial && !$criteria) { - return count($this->getContentVersions()); - } - $query = ContentVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - - return count($this->collContentVersions); - } - - /** - * 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 (!in_array($l, $this->collContentVersions->getArrayCopy(), true)) { // 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. - * @return Content The current object (for fluent API support) - */ - 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[]= clone $contentVersion; - $contentVersion->setContent(null); - } - - return $this; - } - - /** - * Clears out the collFolders 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 Content The current object (for fluent API support) - * @see addFolders() - */ - public function clearFolders() - { - $this->collFolders = null; // important to set this to null since that means it is uninitialized - $this->collFoldersPartial = null; - - return $this; - } - - /** - * Initializes the collFolders collection. - * - * By default this just sets the collFolders collection to an empty collection (like clearFolders()); - * 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. - * - * @return void - */ - public function initFolders() - { - $this->collFolders = new PropelObjectCollection(); - $this->collFolders->setModel('Folder'); - } - - /** - * Gets a collection of Folder objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Folder[] List of Folder objects - */ - public function getFolders($criteria = null, PropelPDO $con = null) - { - if (null === $this->collFolders || null !== $criteria) { - if ($this->isNew() && null === $this->collFolders) { - // return empty collection - $this->initFolders(); - } else { - $collFolders = FolderQuery::create(null, $criteria) - ->filterByContent($this) - ->find($con); - if (null !== $criteria) { - return $collFolders; - } - $this->collFolders = $collFolders; - } - } - - return $this->collFolders; - } - - /** - * Sets a collection of Folder objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * 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 $folders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Content The current object (for fluent API support) - */ - public function setFolders(PropelCollection $folders, PropelPDO $con = null) - { - $this->clearFolders(); - $currentFolders = $this->getFolders(); - - $this->foldersScheduledForDeletion = $currentFolders->diff($folders); - - foreach ($folders as $folder) { - if (!$currentFolders->contains($folder)) { - $this->doAddFolder($folder); - } - } - - $this->collFolders = $folders; - - return $this; - } - - /** - * Gets the number of Folder objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Folder objects - */ - public function countFolders($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collFolders || null !== $criteria) { - if ($this->isNew() && null === $this->collFolders) { - return 0; - } else { - $query = FolderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByContent($this) - ->count($con); - } - } else { - return count($this->collFolders); - } - } - - /** - * Associate a Folder object to this object - * through the content_folder cross reference table. - * - * @param Folder $folder The ContentFolder object to relate - * @return Content The current object (for fluent API support) - */ - public function addFolder(Folder $folder) - { - if ($this->collFolders === null) { - $this->initFolders(); - } - if (!$this->collFolders->contains($folder)) { // only add it if the **same** object is not already associated - $this->doAddFolder($folder); - - $this->collFolders[]= $folder; - } - - return $this; - } - - /** - * @param Folder $folder The folder object to add. - */ - protected function doAddFolder($folder) - { - $contentFolder = new ContentFolder(); - $contentFolder->setFolder($folder); - $this->addContentFolder($contentFolder); - } - - /** - * Remove a Folder object to this object - * through the content_folder cross reference table. - * - * @param Folder $folder The ContentFolder object to relate - * @return Content The current object (for fluent API support) - */ - public function removeFolder(Folder $folder) - { - if ($this->getFolders()->contains($folder)) { - $this->collFolders->remove($this->collFolders->search($folder)); - if (null === $this->foldersScheduledForDeletion) { - $this->foldersScheduledForDeletion = clone $this->collFolders; - $this->foldersScheduledForDeletion->clear(); - } - $this->foldersScheduledForDeletion[]= $folder; - } - - return $this; - } - - /** - * 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentFolders) { - foreach ($this->collContentFolders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentI18ns) { - foreach ($this->collContentI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentVersions) { - foreach ($this->collContentVersions as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFolders) { - foreach ($this->collFolders as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; - if ($this->collContentFolders instanceof PropelCollection) { - $this->collContentFolders->clearIterator(); - } - $this->collContentFolders = null; - if ($this->collContentI18ns instanceof PropelCollection) { - $this->collContentI18ns->clearIterator(); - } - $this->collContentI18ns = null; - if ($this->collContentVersions instanceof PropelCollection) { - $this->collContentVersions->clearIterator(); - } - $this->collContentVersions = null; - if ($this->collFolders instanceof PropelCollection) { - $this->collFolders->clearIterator(); - } - $this->collFolders = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ContentPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Content The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ContentPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Content The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ContentI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collContentI18ns) { - foreach ($this->collContentI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ContentI18n(); - $translation->setLocale($locale); - } else { - $translation = ContentI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addContentI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Content The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ContentI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collContentI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collContentI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ContentI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - 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/BaseContentAssoc.php b/core/lib/Thelia/Model/om/BaseContentAssoc.php deleted file mode 100755 index e661951a8..000000000 --- a/core/lib/Thelia/Model/om/BaseContentAssoc.php +++ /dev/null @@ -1,1484 +0,0 @@ -id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - return $this->content_id; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ContentAssoc The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ContentAssocPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return ContentAssoc The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = ContentAssocPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return ContentAssoc The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = ContentAssocPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return ContentAssoc The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = ContentAssocPeer::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return ContentAssoc The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ContentAssocPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ContentAssoc The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ContentAssocPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ContentAssoc The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ContentAssocPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->content_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = ContentAssocPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ContentAssoc object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ContentAssocPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCategory = null; - $this->aProduct = null; - $this->aContent = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ContentAssocQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ContentAssocPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ContentAssocPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ContentAssocPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ContentAssocPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ContentAssocPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ContentAssocPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(ContentAssocPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(ContentAssocPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; - } - if ($this->isColumnModified(ContentAssocPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(ContentAssocPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ContentAssocPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `content_assoc` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`content_id`': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aContent !== null) { - if (!$this->aContent->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures()); - } - } - - - if (($retval = ContentAssocPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentAssocPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCategoryId(); - break; - case 2: - return $this->getProductId(); - break; - case 3: - return $this->getContentId(); - break; - case 4: - return $this->getPosition(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ContentAssoc'][$this->getPrimaryKey()] = true; - $keys = ContentAssocPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getProductId(), - $keys[3] => $this->getContentId(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentAssocPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCategoryId($value); - break; - case 2: - $this->setProductId($value); - break; - case 3: - $this->setContentId($value); - break; - case 4: - $this->setPosition($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ContentAssocPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setContentId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - - if ($this->isColumnModified(ContentAssocPeer::ID)) $criteria->add(ContentAssocPeer::ID, $this->id); - if ($this->isColumnModified(ContentAssocPeer::CATEGORY_ID)) $criteria->add(ContentAssocPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(ContentAssocPeer::PRODUCT_ID)) $criteria->add(ContentAssocPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(ContentAssocPeer::CONTENT_ID)) $criteria->add(ContentAssocPeer::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(ContentAssocPeer::POSITION)) $criteria->add(ContentAssocPeer::POSITION, $this->position); - if ($this->isColumnModified(ContentAssocPeer::CREATED_AT)) $criteria->add(ContentAssocPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ContentAssocPeer::UPDATED_AT)) $criteria->add(ContentAssocPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - $criteria->add(ContentAssocPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of ContentAssoc (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setProductId($this->getProductId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return ContentAssoc Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ContentAssocPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ContentAssocPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addContentAssocs($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addContentAssocs($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return ContentAssoc The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(Content $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Content object, it will not be re-added. - if ($v !== null) { - $v->addContentAssoc($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addContentAssocs($this); - */ - } - - return $this->aContent; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->category_id = null; - $this->product_id = null; - $this->content_id = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCategory = null; - $this->aProduct = null; - $this->aContent = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ContentAssocPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ContentAssoc The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ContentAssocPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php b/core/lib/Thelia/Model/om/BaseContentAssocPeer.php deleted file mode 100755 index 646dd4003..000000000 --- a/core/lib/Thelia/Model/om/BaseContentAssocPeer.php +++ /dev/null @@ -1,1780 +0,0 @@ - array ('Id', 'CategoryId', 'ProductId', 'ContentId', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'categoryId', 'productId', 'contentId', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID, ContentAssocPeer::CATEGORY_ID, ContentAssocPeer::PRODUCT_ID, ContentAssocPeer::CONTENT_ID, ContentAssocPeer::POSITION, ContentAssocPeer::CREATED_AT, ContentAssocPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CATEGORY_ID', 'PRODUCT_ID', 'CONTENT_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'category_id', 'product_id', 'content_id', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ContentAssocPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CategoryId' => 1, 'ProductId' => 2, 'ContentId' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'categoryId' => 1, 'productId' => 2, 'contentId' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (ContentAssocPeer::ID => 0, ContentAssocPeer::CATEGORY_ID => 1, ContentAssocPeer::PRODUCT_ID => 2, ContentAssocPeer::CONTENT_ID => 3, ContentAssocPeer::POSITION => 4, ContentAssocPeer::CREATED_AT => 5, ContentAssocPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CATEGORY_ID' => 1, 'PRODUCT_ID' => 2, 'CONTENT_ID' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'category_id' => 1, 'product_id' => 2, 'content_id' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ContentAssocPeer::getFieldNames($toType); - $key = isset(ContentAssocPeer::$fieldKeys[$fromType][$name]) ? ContentAssocPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentAssocPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ContentAssocPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ContentAssocPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ContentAssocPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ContentAssocPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ContentAssocPeer::ID); - $criteria->addSelectColumn(ContentAssocPeer::CATEGORY_ID); - $criteria->addSelectColumn(ContentAssocPeer::PRODUCT_ID); - $criteria->addSelectColumn(ContentAssocPeer::CONTENT_ID); - $criteria->addSelectColumn(ContentAssocPeer::POSITION); - $criteria->addSelectColumn(ContentAssocPeer::CREATED_AT); - $criteria->addSelectColumn(ContentAssocPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.content_id'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return ContentAssoc - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ContentAssocPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ContentAssocPeer::populateObjects(ContentAssocPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ContentAssocPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param ContentAssoc $obj A ContentAssoc object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ContentAssocPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A ContentAssoc object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof ContentAssoc) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ContentAssoc object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ContentAssocPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return ContentAssoc Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ContentAssocPeer::$instances[$key])) { - return ContentAssocPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ContentAssocPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ContentAssocPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to content_assoc - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ContentAssocPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ContentAssocPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (ContentAssoc object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ContentAssocPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ContentAssocPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ContentAssocPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ContentAssocPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ContentAssocPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ContentAssoc) to $obj2 (Category) - $obj2->addContentAssoc($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ContentAssoc) to $obj2 (Product) - $obj2->addContentAssoc($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with their Content objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ContentAssoc) to $obj2 (Content) - $obj2->addContentAssoc($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ContentAssoc objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category) - $obj2->addContentAssoc($obj1); - } // if joined row not null - - // Add objects for joined Product rows - - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ProductPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product) - $obj3->addContentAssoc($obj1); - } // if joined row not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj4 (Content) - $obj4->addContentAssoc($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentAssocPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Product) - $obj2->addContentAssoc($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content) - $obj3->addContentAssoc($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category) - $obj2->addContentAssoc($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Content) - $obj3->addContentAssoc($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentAssoc objects pre-filled with all related objects except Content. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentAssoc objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - } - - ContentAssocPeer::addSelectColumns($criteria); - $startcol2 = ContentAssocPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentAssocPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ContentAssocPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentAssocPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentAssocPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentAssocPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj2 (Category) - $obj2->addContentAssoc($obj1); - - } // if joined row is not null - - // Add objects for joined Product rows - - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ProductPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (ContentAssoc) to the collection in $obj3 (Product) - $obj3->addContentAssoc($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME)->getTable(ContentAssocPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseContentAssocPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseContentAssocPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ContentAssocTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ContentAssocPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ContentAssoc or Criteria object. - * - * @param mixed $values Criteria or ContentAssoc object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ContentAssoc object - } - - if ($criteria->containsKey(ContentAssocPeer::ID) && $criteria->keyContainsValue(ContentAssocPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentAssocPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a ContentAssoc or Criteria object. - * - * @param mixed $values Criteria or ContentAssoc object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ContentAssocPeer::ID); - $value = $criteria->remove(ContentAssocPeer::ID); - if ($value) { - $selectCriteria->add(ContentAssocPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentAssocPeer::TABLE_NAME); - } - - } else { // $values is ContentAssoc object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the content_assoc table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ContentAssocPeer::TABLE_NAME, $con, ContentAssocPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ContentAssocPeer::clearInstancePool(); - ContentAssocPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ContentAssoc or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ContentAssoc object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ContentAssocPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ContentAssoc) { // it's a model object - // invalidate the cache for this single object - ContentAssocPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - $criteria->add(ContentAssocPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ContentAssocPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ContentAssocPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ContentAssocPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ContentAssoc object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param ContentAssoc $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ContentAssocPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ContentAssocPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ContentAssocPeer::DATABASE_NAME, ContentAssocPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return ContentAssoc - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ContentAssocPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - $criteria->add(ContentAssocPeer::ID, $pk); - - $v = ContentAssocPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return ContentAssoc[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ContentAssocPeer::DATABASE_NAME); - $criteria->add(ContentAssocPeer::ID, $pks, Criteria::IN); - $objs = ContentAssocPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseContentAssocPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseContentAssocPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php b/core/lib/Thelia/Model/om/BaseContentAssocQuery.php deleted file mode 100755 index 709046cf2..000000000 --- a/core/lib/Thelia/Model/om/BaseContentAssocQuery.php +++ /dev/null @@ -1,879 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ContentAssocPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ContentAssocPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ContentAssoc A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ContentAssoc A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `category_id`, `product_id`, `content_id`, `position`, `created_at`, `updated_at` FROM `content_assoc` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentAssoc(); - $obj->hydrate($row); - ContentAssocPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ContentAssoc|ContentAssoc[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|ContentAssoc[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ContentAssocPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ContentAssocPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ContentAssocPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ContentAssocPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 - * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ContentAssocPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ContentAssocPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Content object - * - * @param Content|PropelObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentAssocQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof Content) { - return $this - ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentAssocPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Exclude object from result - * - * @param ContentAssoc $contentAssoc Object to remove from the list of results - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function prune($contentAssoc = null) - { - if ($contentAssoc) { - $this->addUsingAlias(ContentAssocPeer::ID, $contentAssoc->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ContentAssocPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ContentAssocPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ContentAssocPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ContentAssocPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ContentAssocPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ContentAssocQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ContentAssocPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseContentFolder.php b/core/lib/Thelia/Model/om/BaseContentFolder.php deleted file mode 100755 index 4d4050d29..000000000 --- a/core/lib/Thelia/Model/om/BaseContentFolder.php +++ /dev/null @@ -1,1228 +0,0 @@ -content_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - return $this->folder_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return ContentFolder The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = ContentFolderPeer::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return ContentFolder The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = ContentFolderPeer::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ContentFolder The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ContentFolderPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ContentFolder The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ContentFolderPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->content_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->folder_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = ContentFolderPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ContentFolder object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ContentFolderPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aContent = null; - $this->aFolder = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ContentFolderQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ContentFolderPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ContentFolderPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; - } - if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; - } - if ($this->isColumnModified(ContentFolderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ContentFolderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `content_folder` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`content_id`': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case '`folder_id`': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aContent !== null) { - if (!$this->aContent->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures()); - } - } - - if ($this->aFolder !== null) { - if (!$this->aFolder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures()); - } - } - - - if (($retval = ContentFolderPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentFolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getContentId(); - break; - case 1: - return $this->getFolderId(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ContentFolder'][serialize($this->getPrimaryKey())] = true; - $keys = ContentFolderPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getContentId(), - $keys[1] => $this->getFolderId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ContentFolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setContentId($value); - break; - case 1: - $this->setFolderId($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ContentFolderPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setContentId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setFolderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME); - - if ($this->isColumnModified(ContentFolderPeer::CONTENT_ID)) $criteria->add(ContentFolderPeer::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(ContentFolderPeer::FOLDER_ID)) $criteria->add(ContentFolderPeer::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(ContentFolderPeer::CREATED_AT)) $criteria->add(ContentFolderPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ContentFolderPeer::UPDATED_AT)) $criteria->add(ContentFolderPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME); - $criteria->add(ContentFolderPeer::CONTENT_ID, $this->content_id); - $criteria->add(ContentFolderPeer::FOLDER_ID, $this->folder_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getContentId(); - $pks[1] = $this->getFolderId(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setContentId($keys[0]); - $this->setFolderId($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getContentId()) && (null === $this->getFolderId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of ContentFolder (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setContentId($this->getContentId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return ContentFolder Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ContentFolderPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ContentFolderPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return ContentFolder The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(Content $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Content object, it will not be re-added. - if ($v !== null) { - $v->addContentFolder($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addContentFolders($this); - */ - } - - return $this->aContent; - } - - /** - * Declares an association between this object and a Folder object. - * - * @param Folder $v - * @return ContentFolder The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(Folder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Folder object, it will not be re-added. - if ($v !== null) { - $v->addContentFolder($this); - } - - - return $this; - } - - - /** - * Get the associated Folder object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addContentFolders($this); - */ - } - - return $this->aFolder; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->content_id = null; - $this->folder_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aContent = null; - $this->aFolder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ContentFolderPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ContentFolder The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ContentFolderPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php b/core/lib/Thelia/Model/om/BaseContentFolderPeer.php deleted file mode 100755 index 0af59f3e4..000000000 --- a/core/lib/Thelia/Model/om/BaseContentFolderPeer.php +++ /dev/null @@ -1,1400 +0,0 @@ - array ('ContentId', 'FolderId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('contentId', 'folderId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID, ContentFolderPeer::FOLDER_ID, ContentFolderPeer::CREATED_AT, ContentFolderPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID', 'FOLDER_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('content_id', 'folder_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ContentFolderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('ContentId' => 0, 'FolderId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('contentId' => 0, 'folderId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (ContentFolderPeer::CONTENT_ID => 0, ContentFolderPeer::FOLDER_ID => 1, ContentFolderPeer::CREATED_AT => 2, ContentFolderPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('CONTENT_ID' => 0, 'FOLDER_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('content_id' => 0, 'folder_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ContentFolderPeer::getFieldNames($toType); - $key = isset(ContentFolderPeer::$fieldKeys[$fromType][$name]) ? ContentFolderPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentFolderPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ContentFolderPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ContentFolderPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ContentFolderPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ContentFolderPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ContentFolderPeer::CONTENT_ID); - $criteria->addSelectColumn(ContentFolderPeer::FOLDER_ID); - $criteria->addSelectColumn(ContentFolderPeer::CREATED_AT); - $criteria->addSelectColumn(ContentFolderPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.content_id'); - $criteria->addSelectColumn($alias . '.folder_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return ContentFolder - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ContentFolderPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ContentFolderPeer::populateObjects(ContentFolderPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ContentFolderPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param ContentFolder $obj A ContentFolder object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = serialize(array((string) $obj->getContentId(), (string) $obj->getFolderId())); - } // if key === null - ContentFolderPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A ContentFolder object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof ContentFolder) { - $key = serialize(array((string) $value->getContentId(), (string) $value->getFolderId())); - } elseif (is_array($value) && count($value) === 2) { - // assume we've been passed a primary key - $key = serialize(array((string) $value[0], (string) $value[1])); - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ContentFolder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ContentFolderPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return ContentFolder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ContentFolderPeer::$instances[$key])) { - return ContentFolderPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ContentFolderPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ContentFolderPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to content_folder - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (int) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ContentFolderPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ContentFolderPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (ContentFolder object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ContentFolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ContentFolderPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ContentFolderPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ContentFolderPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ContentFolder objects pre-filled with their Content objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentFolder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - } - - ContentFolderPeer::addSelectColumns($criteria); - $startcol = ContentFolderPeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentFolderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ContentFolder) to $obj2 (Content) - $obj2->addContentFolder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentFolder objects pre-filled with their Folder objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentFolder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - } - - ContentFolderPeer::addSelectColumns($criteria); - $startcol = ContentFolderPeer::NUM_HYDRATE_COLUMNS; - FolderPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentFolderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FolderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FolderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FolderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ContentFolder) to $obj2 (Folder) - $obj2->addContentFolder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ContentFolder objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentFolder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - } - - ContentFolderPeer::addSelectColumns($criteria); - $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentFolderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Content rows - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ContentFolder) to the collection in $obj2 (Content) - $obj2->addContentFolder($obj1); - } // if joined row not null - - // Add objects for joined Folder rows - - $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FolderPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FolderPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FolderPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (ContentFolder) to the collection in $obj3 (Folder) - $obj3->addContentFolder($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentFolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ContentFolder objects pre-filled with all related objects except Content. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentFolder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - } - - ContentFolderPeer::addSelectColumns($criteria); - $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentFolderPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentFolderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Folder rows - - $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FolderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FolderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FolderPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ContentFolder) to the collection in $obj2 (Folder) - $obj2->addContentFolder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ContentFolder objects pre-filled with all related objects except Folder. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ContentFolder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - } - - ContentFolderPeer::addSelectColumns($criteria); - $startcol2 = ContentFolderPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentFolderPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentFolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentFolderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentFolderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Content rows - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ContentFolder) to the collection in $obj2 (Content) - $obj2->addContentFolder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ContentFolderPeer::DATABASE_NAME)->getTable(ContentFolderPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseContentFolderPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseContentFolderPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ContentFolderTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ContentFolderPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ContentFolder or Criteria object. - * - * @param mixed $values Criteria or ContentFolder object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ContentFolder object - } - - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a ContentFolder or Criteria object. - * - * @param mixed $values Criteria or ContentFolder object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ContentFolderPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ContentFolderPeer::CONTENT_ID); - $value = $criteria->remove(ContentFolderPeer::CONTENT_ID); - if ($value) { - $selectCriteria->add(ContentFolderPeer::CONTENT_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ContentFolderPeer::FOLDER_ID); - $value = $criteria->remove(ContentFolderPeer::FOLDER_ID); - if ($value) { - $selectCriteria->add(ContentFolderPeer::FOLDER_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentFolderPeer::TABLE_NAME); - } - - } else { // $values is ContentFolder object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the content_folder table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ContentFolderPeer::TABLE_NAME, $con, ContentFolderPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ContentFolderPeer::clearInstancePool(); - ContentFolderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ContentFolder or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ContentFolder object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ContentFolderPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ContentFolder) { // it's a model object - // invalidate the cache for this single object - ContentFolderPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(ContentFolderPeer::CONTENT_ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ContentFolderPeer::FOLDER_ID, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ContentFolderPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ContentFolderPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ContentFolderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ContentFolder object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param ContentFolder $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ContentFolderPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ContentFolderPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ContentFolderPeer::DATABASE_NAME, ContentFolderPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $content_id - * @param int $folder_id - * @param PropelPDO $con - * @return ContentFolder - */ - public static function retrieveByPK($content_id, $folder_id, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $content_id, (string) $folder_id)); - if (null !== ($obj = ContentFolderPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ContentFolderPeer::DATABASE_NAME); - $criteria->add(ContentFolderPeer::CONTENT_ID, $content_id); - $criteria->add(ContentFolderPeer::FOLDER_ID, $folder_id); - $v = ContentFolderPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseContentFolderPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseContentFolderPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php b/core/lib/Thelia/Model/om/BaseContentFolderQuery.php deleted file mode 100755 index 0a44bc555..000000000 --- a/core/lib/Thelia/Model/om/BaseContentFolderQuery.php +++ /dev/null @@ -1,660 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34), $con); - * - * - * @param array $key Primary key to use for the query - A Primary key composition: [$content_id, $folder_id] - * @param PropelPDO $con an optional connection object - * - * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ContentFolderPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ContentFolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ContentFolder A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `content_id`, `folder_id`, `created_at`, `updated_at` FROM `content_folder` WHERE `content_id` = :p0 AND `folder_id` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ContentFolder(); - $obj->hydrate($row); - ContentFolderPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ContentFolder|ContentFolder[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|ContentFolder[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $key[1], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(ContentFolderPeer::CONTENT_ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ContentFolderPeer::FOLDER_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 - * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentFolderPeer::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 - * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentFolderPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Content object - * - * @param Content|PropelObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof Content) { - return $this - ->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentFolderPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Filter the query by a related Folder object - * - * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentFolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof Folder) { - return $this - ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentFolderPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Exclude object from result - * - * @param ContentFolder $contentFolder Object to remove from the list of results - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function prune($contentFolder = null) - { - if ($contentFolder) { - $this->addCond('pruneCond0', $this->getAliasedColName(ContentFolderPeer::CONTENT_ID), $contentFolder->getContentId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ContentFolderPeer::FOLDER_ID), $contentFolder->getFolderId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ContentFolderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ContentFolderPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ContentFolderPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ContentFolderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ContentFolderPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ContentFolderQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ContentFolderPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseContentI18n.php b/core/lib/Thelia/Model/om/BaseContentI18n.php deleted file mode 100755 index b55e21f28..000000000 --- a/core/lib/Thelia/Model/om/BaseContentI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseContentI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ContentI18nPeer::ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ContentI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ContentI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ContentI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ContentI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ContentI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ContentI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ContentI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ContentI18n 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(ContentI18nPeer::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 = ContentI18nPeer::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(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ContentI18nQuery::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(ContentI18nPeer::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); - ContentI18nPeer::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(ContentI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ContentI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ContentI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ContentI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ContentI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ContentI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `content_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $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 = ContentI18nPeer::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 = ContentI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ContentI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ContentI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ContentI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - 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 = ContentI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ContentI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ContentI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ContentI18nPeer::ID)) $criteria->add(ContentI18nPeer::ID, $this->id); - if ($this->isColumnModified(ContentI18nPeer::LOCALE)) $criteria->add(ContentI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ContentI18nPeer::TITLE)) $criteria->add(ContentI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ContentI18nPeer::DESCRIPTION)) $criteria->add(ContentI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ContentI18nPeer::CHAPO)) $criteria->add(ContentI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ContentI18nPeer::POSTSCRIPTUM)) $criteria->add(ContentI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ContentI18nPeer::DATABASE_NAME); - $criteria->add(ContentI18nPeer::ID, $this->id); - $criteria->add(ContentI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ContentI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ContentI18n 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 ContentI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ContentI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return ContentI18n 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->addContentI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->addContentI18ns($this); - */ - } - - return $this->aContent; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aContent = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ContentI18nPeer::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/BaseContentI18nPeer.php b/core/lib/Thelia/Model/om/BaseContentI18nPeer.php deleted file mode 100755 index 364753e50..000000000 --- a/core/lib/Thelia/Model/om/BaseContentI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ContentI18nPeer::ID, ContentI18nPeer::LOCALE, ContentI18nPeer::TITLE, ContentI18nPeer::DESCRIPTION, ContentI18nPeer::CHAPO, ContentI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ContentI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ContentI18nPeer::ID => 0, ContentI18nPeer::LOCALE => 1, ContentI18nPeer::TITLE => 2, ContentI18nPeer::DESCRIPTION => 3, ContentI18nPeer::CHAPO => 4, ContentI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ContentI18nPeer::getFieldNames($toType); - $key = isset(ContentI18nPeer::$fieldKeys[$fromType][$name]) ? ContentI18nPeer::$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(ContentI18nPeer::$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, ContentI18nPeer::$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 ContentI18nPeer::$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. ContentI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ContentI18nPeer::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(ContentI18nPeer::ID); - $criteria->addSelectColumn(ContentI18nPeer::LOCALE); - $criteria->addSelectColumn(ContentI18nPeer::TITLE); - $criteria->addSelectColumn(ContentI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ContentI18nPeer::CHAPO); - $criteria->addSelectColumn(ContentI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ContentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ContentI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ContentI18nPeer::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 ContentI18n - * @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 = ContentI18nPeer::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 ContentI18nPeer::populateObjects(ContentI18nPeer::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 directly (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(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ContentI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ContentI18nPeer::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 ContentI18n $obj A ContentI18n 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->getLocale())); - } // if key === null - ContentI18nPeer::$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 ContentI18n 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 ContentI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ContentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ContentI18nPeer::$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 ContentI18n 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(ContentI18nPeer::$instances[$key])) { - return ContentI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ContentI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ContentI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to content_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ContentI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ContentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ContentI18nPeer::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; - ContentI18nPeer::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 (ContentI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ContentI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ContentI18nPeer::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 + ContentI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ContentI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ContentI18nPeer::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(ContentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentI18nPeer::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 ContentI18n 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 ContentI18n 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(ContentI18nPeer::DATABASE_NAME); - } - - ContentI18nPeer::addSelectColumns($criteria); - $startcol = ContentI18nPeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(ContentI18nPeer::ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ContentI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentI18nPeer::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 (ContentI18n) to $obj2 (Content) - $obj2->addContentI18n($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(ContentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ContentI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ContentI18nPeer::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 ContentI18n 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 ContentI18n 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(ContentI18nPeer::DATABASE_NAME); - } - - ContentI18nPeer::addSelectColumns($criteria); - $startcol2 = ContentI18nPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ContentI18nPeer::ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ContentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ContentI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ContentI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ContentI18nPeer::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 (ContentI18n) to the collection in $obj2 (Content) - $obj2->addContentI18n($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(ContentI18nPeer::DATABASE_NAME)->getTable(ContentI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseContentI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseContentI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ContentI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ContentI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ContentI18n or Criteria object. - * - * @param mixed $values Criteria or ContentI18n 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(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ContentI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ContentI18nPeer::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 ContentI18n or Criteria object. - * - * @param mixed $values Criteria or ContentI18n 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(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ContentI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ContentI18nPeer::ID); - $value = $criteria->remove(ContentI18nPeer::ID); - if ($value) { - $selectCriteria->add(ContentI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ContentI18nPeer::LOCALE); - $value = $criteria->remove(ContentI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ContentI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentI18nPeer::TABLE_NAME); - } - - } else { // $values is ContentI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ContentI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the content_i18n 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(ContentI18nPeer::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(ContentI18nPeer::TABLE_NAME, $con, ContentI18nPeer::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). - ContentI18nPeer::clearInstancePool(); - ContentI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ContentI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ContentI18n 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(ContentI18nPeer::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. - ContentI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ContentI18n) { // it's a model object - // invalidate the cache for this single object - ContentI18nPeer::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(ContentI18nPeer::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(ContentI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ContentI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ContentI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ContentI18nPeer::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); - ContentI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ContentI18n 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 ContentI18n $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(ContentI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ContentI18nPeer::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(ContentI18nPeer::DATABASE_NAME, ContentI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ContentI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ContentI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ContentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ContentI18nPeer::DATABASE_NAME); - $criteria->add(ContentI18nPeer::ID, $id); - $criteria->add(ContentI18nPeer::LOCALE, $locale); - $v = ContentI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseContentI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseContentI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php b/core/lib/Thelia/Model/om/BaseContentI18nQuery.php deleted file mode 100755 index 44aa8dab2..000000000 --- a/core/lib/Thelia/Model/om/BaseContentI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ContentI18n|ContentI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ContentI18nPeer::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(ContentI18nPeer::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 ContentI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `content_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ContentI18n(); - $obj->hydrate($row); - ContentI18nPeer::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 ContentI18n|ContentI18n[]|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|ContentI18n[]|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 ContentI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ContentI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ContentI18nPeer::LOCALE, $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 ContentI18nQuery 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(ContentI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ContentI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 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 ContentI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ContentI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ContentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ContentI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ContentI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ContentI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ContentI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ContentI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ContentI18nPeer::POSTSCRIPTUM, $postscriptum, $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 ContentI18nQuery 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(ContentI18nPeer::ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ContentI18nPeer::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 ContentI18nQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Exclude object from result - * - * @param ContentI18n $contentI18n Object to remove from the list of results - * - * @return ContentI18nQuery The current query, for fluid interface - */ - public function prune($contentI18n = null) - { - if ($contentI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ContentI18nPeer::ID), $contentI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ContentI18nPeer::LOCALE), $contentI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseContentPeer.php b/core/lib/Thelia/Model/om/BaseContentPeer.php deleted file mode 100755 index 070b2830c..000000000 --- a/core/lib/Thelia/Model/om/BaseContentPeer.php +++ /dev/null @@ -1,875 +0,0 @@ - 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, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ContentPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, '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, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ContentPeer::getFieldNames($toType); - $key = isset(ContentPeer::$fieldKeys[$fromType][$name]) ? ContentPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ContentPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ContentPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ContentPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ContentPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ContentPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ContentPeer::ID); - $criteria->addSelectColumn(ContentPeer::VISIBLE); - $criteria->addSelectColumn(ContentPeer::POSITION); - $criteria->addSelectColumn(ContentPeer::CREATED_AT); - $criteria->addSelectColumn(ContentPeer::UPDATED_AT); - $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'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ContentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ContentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ContentPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Content - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ContentPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ContentPeer::populateObjects(ContentPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ContentPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ContentPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Content $obj A Content object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ContentPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Content object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Content) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Content object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ContentPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Content Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ContentPeer::$instances[$key])) { - return ContentPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ContentPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ContentPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to content - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in RewritingPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingPeer::clearInstancePool(); - // Invalidate objects in ContentFolderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentFolderPeer::clearInstancePool(); - // 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(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ContentPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ContentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ContentPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ContentPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Content object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ContentPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ContentPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ContentPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ContentPeer::DATABASE_NAME)->getTable(ContentPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseContentPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseContentPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ContentTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ContentPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Content or Criteria object. - * - * @param mixed $values Criteria or Content object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Content object - } - - if ($criteria->containsKey(ContentPeer::ID) && $criteria->keyContainsValue(ContentPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ContentPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ContentPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Content or Criteria object. - * - * @param mixed $values Criteria or Content object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ContentPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ContentPeer::ID); - $value = $criteria->remove(ContentPeer::ID); - if ($value) { - $selectCriteria->add(ContentPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ContentPeer::TABLE_NAME); - } - - } else { // $values is Content object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ContentPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the content table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ContentPeer::TABLE_NAME, $con, ContentPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ContentPeer::clearInstancePool(); - ContentPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Content or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Content object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ContentPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Content) { // it's a model object - // invalidate the cache for this single object - ContentPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ContentPeer::DATABASE_NAME); - $criteria->add(ContentPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ContentPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ContentPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ContentPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Content object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Content $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ContentPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ContentPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ContentPeer::DATABASE_NAME, ContentPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Content - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ContentPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ContentPeer::DATABASE_NAME); - $criteria->add(ContentPeer::ID, $pk); - - $v = ContentPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Content[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ContentPeer::DATABASE_NAME); - $criteria->add(ContentPeer::ID, $pks, Criteria::IN); - $objs = ContentPeer::doSelect($criteria, $con); - } - - return $objs; - } - - // 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. -// -BaseContentPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseContentQuery.php b/core/lib/Thelia/Model/om/BaseContentQuery.php deleted file mode 100755 index 5cb162d1a..000000000 --- a/core/lib/Thelia/Model/om/BaseContentQuery.php +++ /dev/null @@ -1,1292 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Content|Content[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ContentPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ContentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Content A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Content A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `content` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Content(); - $obj->hydrate($row); - ContentPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Content|Content[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Content[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ContentPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ContentPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ContentPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ContentPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 - * - * - * @param mixed $visible The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByVisible($visible = null, $comparison = null) - { - if (is_array($visible)) { - $useMinMax = false; - if (isset($visible['min'])) { - $this->addUsingAlias(ContentPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($visible['max'])) { - $this->addUsingAlias(ContentPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentPeer::VISIBLE, $visible, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ContentPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ContentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query 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 - * $query->filterByVersion(array('max' => 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 - * - * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof ContentAssoc) { - return $this - ->addUsingAlias(ContentPeer::ID, $contentAssoc->getContentId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - - /** - * Filter the query by a related Image object - * - * @param Image|PropelObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(ContentPeer::ID, $image->getContentId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related Document object - * - * @param Document|PropelObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(ContentPeer::ID, $document->getContentId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Filter the query by a related Rewriting object - * - * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof Rewriting) { - return $this - ->addUsingAlias(ContentPeer::ID, $rewriting->getContentId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - - /** - * Filter the query by a related ContentFolder object - * - * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentFolder($contentFolder, $comparison = null) - { - if ($contentFolder instanceof ContentFolder) { - return $this - ->addUsingAlias(ContentPeer::ID, $contentFolder->getContentId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { - return $this - ->useContentFolderQuery() - ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentFolder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentFolder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentFolder'); - } - - return $this; - } - - /** - * Use the ContentFolder relation ContentFolder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query - */ - public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinContentFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); - } - - /** - * Filter the query by a related ContentI18n object - * - * @param ContentI18n|PropelObjectCollection $contentI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ContentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentI18n($contentI18n, $comparison = null) - { - if ($contentI18n instanceof ContentI18n) { - return $this - ->addUsingAlias(ContentPeer::ID, $contentI18n->getId(), $comparison); - } elseif ($contentI18n instanceof PropelObjectCollection) { - return $this - ->useContentI18nQuery() - ->filterByPrimaryKeys($contentI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentI18n() only accepts arguments of type ContentI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentI18n 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 joinContentI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentI18n'); - } - - return $this; - } - - /** - * Use the ContentI18n relation ContentI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentI18nQuery A secondary query class using the current class as primary query - */ - public function useContentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinContentI18n($relationAlias, $joinType) - ->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'); - } - - /** - * Filter the query by a related Folder object - * using the content_folder table as cross reference - * - * @param Folder $folder 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 - */ - public function filterByFolder($folder, $comparison = Criteria::EQUAL) - { - return $this - ->useContentFolderQuery() - ->filterByFolder($folder, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Content $content Object to remove from the list of results - * - * @return ContentQuery The current query, for fluid interface - */ - public function prune($content = null) - { - if ($content) { - $this->addUsingAlias(ContentPeer::ID, $content->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ContentQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ContentPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ContentQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ContentPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ContentQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ContentPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ContentQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ContentPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ContentQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ContentPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ContentQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ContentPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; - - return $this - ->joinContentI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ContentQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ContentI18n'); - $this->with['ContentI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ContentI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentI18n', 'Thelia\Model\ContentI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseContentVersion.php b/core/lib/Thelia/Model/om/BaseContentVersion.php deleted file mode 100755 index 423d1a2ac..000000000 --- a/core/lib/Thelia/Model/om/BaseContentVersion.php +++ /dev/null @@ -1,1395 +0,0 @@ -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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - 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; - } - - $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. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // 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 deleted file mode 100755 index 1e2888f75..000000000 --- a/core/lib/Thelia/Model/om/BaseContentVersionPeer.php +++ /dev/null @@ -1,1026 +0,0 @@ - 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 directly (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($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ContentVersionPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - 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($row = 0, $colnum = 0) - { - 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 deleted file mode 100755 index 576a3ac02..000000000 --- a/core/lib/Thelia/Model/om/BaseContentVersionQuery.php +++ /dev/null @@ -1,684 +0,0 @@ -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 - * $query->filterById(array('max' => 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)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ContentVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ContentVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentVersionPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByVisible(array('max' => 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 - * $query->filterByPosition(array('max' => 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 - * $query->filterByVersion(array('max' => 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)) { - $useMinMax = false; - if (isset($version['min'])) { - $this->addUsingAlias(ContentVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($version['max'])) { - $this->addUsingAlias(ContentVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ContentVersionPeer::VERSION, $version, $comparison); - } - - /** - * 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/BaseCountry.php b/core/lib/Thelia/Model/om/BaseCountry.php deleted file mode 100755 index 964ccac65..000000000 --- a/core/lib/Thelia/Model/om/BaseCountry.php +++ /dev/null @@ -1,2142 +0,0 @@ -id; - } - - /** - * Get the [area_id] column value. - * - * @return int - */ - public function getAreaId() - { - return $this->area_id; - } - - /** - * Get the [isocode] column value. - * - * @return string - */ - public function getIsocode() - { - return $this->isocode; - } - - /** - * Get the [isoalpha2] column value. - * - * @return string - */ - public function getIsoalpha2() - { - return $this->isoalpha2; - } - - /** - * Get the [isoalpha3] column value. - * - * @return string - */ - public function getIsoalpha3() - { - return $this->isoalpha3; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Country The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CountryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [area_id] column. - * - * @param int $v new value - * @return Country The current object (for fluent API support) - */ - public function setAreaId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->area_id !== $v) { - $this->area_id = $v; - $this->modifiedColumns[] = CountryPeer::AREA_ID; - } - - if ($this->aArea !== null && $this->aArea->getId() !== $v) { - $this->aArea = null; - } - - - return $this; - } // setAreaId() - - /** - * Set the value of [isocode] column. - * - * @param string $v new value - * @return Country The current object (for fluent API support) - */ - public function setIsocode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->isocode !== $v) { - $this->isocode = $v; - $this->modifiedColumns[] = CountryPeer::ISOCODE; - } - - - return $this; - } // setIsocode() - - /** - * Set the value of [isoalpha2] column. - * - * @param string $v new value - * @return Country The current object (for fluent API support) - */ - public function setIsoalpha2($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->isoalpha2 !== $v) { - $this->isoalpha2 = $v; - $this->modifiedColumns[] = CountryPeer::ISOALPHA2; - } - - - return $this; - } // setIsoalpha2() - - /** - * Set the value of [isoalpha3] column. - * - * @param string $v new value - * @return Country The current object (for fluent API support) - */ - public function setIsoalpha3($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->isoalpha3 !== $v) { - $this->isoalpha3 = $v; - $this->modifiedColumns[] = CountryPeer::ISOALPHA3; - } - - - return $this; - } // setIsoalpha3() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Country The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CountryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Country The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CountryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->area_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->isocode = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->isoalpha2 = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->isoalpha3 = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = CountryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Country object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { - $this->aArea = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CountryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aArea = null; - $this->collTaxRuleCountrys = null; - - $this->collCountryI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CountryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CountryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CountryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CountryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CountryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aArea !== null) { - if ($this->aArea->isModified() || $this->aArea->isNew()) { - $affectedRows += $this->aArea->save($con); - } - $this->setArea($this->aArea); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->taxRuleCountrysScheduledForDeletion !== null) { - if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) { - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) { - // need to save related object because we set the relation to null - $taxRuleCountry->save($con); - } - $this->taxRuleCountrysScheduledForDeletion = null; - } - } - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->countryI18nsScheduledForDeletion !== null) { - if (!$this->countryI18nsScheduledForDeletion->isEmpty()) { - CountryI18nQuery::create() - ->filterByPrimaryKeys($this->countryI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->countryI18nsScheduledForDeletion = null; - } - } - - if ($this->collCountryI18ns !== null) { - foreach ($this->collCountryI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CountryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CountryPeer::AREA_ID)) { - $modifiedColumns[':p' . $index++] = '`area_id`'; - } - if ($this->isColumnModified(CountryPeer::ISOCODE)) { - $modifiedColumns[':p' . $index++] = '`isocode`'; - } - if ($this->isColumnModified(CountryPeer::ISOALPHA2)) { - $modifiedColumns[':p' . $index++] = '`isoalpha2`'; - } - if ($this->isColumnModified(CountryPeer::ISOALPHA3)) { - $modifiedColumns[':p' . $index++] = '`isoalpha3`'; - } - if ($this->isColumnModified(CountryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CountryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `country` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`area_id`': - $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); - break; - case '`isocode`': - $stmt->bindValue($identifier, $this->isocode, PDO::PARAM_STR); - break; - case '`isoalpha2`': - $stmt->bindValue($identifier, $this->isoalpha2, PDO::PARAM_STR); - break; - case '`isoalpha3`': - $stmt->bindValue($identifier, $this->isoalpha3, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aArea !== null) { - if (!$this->aArea->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aArea->getValidationFailures()); - } - } - - - if (($retval = CountryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCountryI18ns !== null) { - foreach ($this->collCountryI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getAreaId(); - break; - case 2: - return $this->getIsocode(); - break; - case 3: - return $this->getIsoalpha2(); - break; - case 4: - return $this->getIsoalpha3(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Country'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Country'][$this->getPrimaryKey()] = true; - $keys = CountryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getAreaId(), - $keys[2] => $this->getIsocode(), - $keys[3] => $this->getIsoalpha2(), - $keys[4] => $this->getIsoalpha3(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aArea) { - $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collTaxRuleCountrys) { - $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collCountryI18ns) { - $result['CountryI18ns'] = $this->collCountryI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setAreaId($value); - break; - case 2: - $this->setIsocode($value); - break; - case 3: - $this->setIsoalpha2($value); - break; - case 4: - $this->setIsoalpha3($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CountryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setIsocode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setIsoalpha2($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setIsoalpha3($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - - if ($this->isColumnModified(CountryPeer::ID)) $criteria->add(CountryPeer::ID, $this->id); - if ($this->isColumnModified(CountryPeer::AREA_ID)) $criteria->add(CountryPeer::AREA_ID, $this->area_id); - if ($this->isColumnModified(CountryPeer::ISOCODE)) $criteria->add(CountryPeer::ISOCODE, $this->isocode); - if ($this->isColumnModified(CountryPeer::ISOALPHA2)) $criteria->add(CountryPeer::ISOALPHA2, $this->isoalpha2); - if ($this->isColumnModified(CountryPeer::ISOALPHA3)) $criteria->add(CountryPeer::ISOALPHA3, $this->isoalpha3); - if ($this->isColumnModified(CountryPeer::CREATED_AT)) $criteria->add(CountryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CountryPeer::UPDATED_AT)) $criteria->add(CountryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - $criteria->add(CountryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Country (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setAreaId($this->getAreaId()); - $copyObj->setIsocode($this->getIsocode()); - $copyObj->setIsoalpha2($this->getIsoalpha2()); - $copyObj->setIsoalpha3($this->getIsoalpha3()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getTaxRuleCountrys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCountryI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCountryI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Country Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CountryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CountryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Area object. - * - * @param Area $v - * @return Country The current object (for fluent API support) - * @throws PropelException - */ - public function setArea(Area $v = null) - { - if ($v === null) { - $this->setAreaId(NULL); - } else { - $this->setAreaId($v->getId()); - } - - $this->aArea = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Area object, it will not be re-added. - if ($v !== null) { - $v->addCountry($this); - } - - - return $this; - } - - - /** - * Get the associated Area object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Area The associated Area object. - * @throws PropelException - */ - public function getArea(PropelPDO $con = null, $doQuery = true) - { - if ($this->aArea === null && ($this->area_id !== null) && $doQuery) { - $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aArea->addCountrys($this); - */ - } - - return $this->aArea; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); - } - if ('CountryI18n' == $relationName) { - $this->initCountryI18ns(); - } - } - - /** - * Clears out the collTaxRuleCountrys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Country The current object (for fluent API support) - * @see addTaxRuleCountrys() - */ - public function clearTaxRuleCountrys() - { - $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized - $this->collTaxRuleCountrysPartial = null; - - return $this; - } - - /** - * reset is the collTaxRuleCountrys collection loaded partially - * - * @return void - */ - public function resetPartialTaxRuleCountrys($v = true) - { - $this->collTaxRuleCountrysPartial = $v; - } - - /** - * Initializes the collTaxRuleCountrys collection. - * - * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initTaxRuleCountrys($overrideExisting = true) - { - if (null !== $this->collTaxRuleCountrys && !$overrideExisting) { - return; - } - $this->collTaxRuleCountrys = new PropelObjectCollection(); - $this->collTaxRuleCountrys->setModel('TaxRuleCountry'); - } - - /** - * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Country is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - * @throws PropelException - */ - public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - // return empty collection - $this->initTaxRuleCountrys(); - } else { - $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria) - ->filterByCountry($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) { - $this->initTaxRuleCountrys(false); - - foreach($collTaxRuleCountrys as $obj) { - if (false == $this->collTaxRuleCountrys->contains($obj)) { - $this->collTaxRuleCountrys->append($obj); - } - } - - $this->collTaxRuleCountrysPartial = true; - } - - $collTaxRuleCountrys->getInternalIterator()->rewind(); - return $collTaxRuleCountrys; - } - - if($partial && $this->collTaxRuleCountrys) { - foreach($this->collTaxRuleCountrys as $obj) { - if($obj->isNew()) { - $collTaxRuleCountrys[] = $obj; - } - } - } - - $this->collTaxRuleCountrys = $collTaxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - } - } - - return $this->collTaxRuleCountrys; - } - - /** - * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $taxRuleCountrys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Country The current object (for fluent API support) - */ - public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) - { - $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - - $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); - - foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { - $taxRuleCountryRemoved->setCountry(null); - } - - $this->collTaxRuleCountrys = null; - foreach ($taxRuleCountrys as $taxRuleCountry) { - $this->addTaxRuleCountry($taxRuleCountry); - } - - $this->collTaxRuleCountrys = $taxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - - return $this; - } - - /** - * Returns the number of related TaxRuleCountry objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxRuleCountry objects. - * @throws PropelException - */ - public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCountry($this) - ->count($con); - } - - return count($this->collTaxRuleCountrys); - } - - /** - * Method called to associate a TaxRuleCountry object to this object - * through the TaxRuleCountry foreign key attribute. - * - * @param TaxRuleCountry $l TaxRuleCountry - * @return Country The current object (for fluent API support) - */ - public function addTaxRuleCountry(TaxRuleCountry $l) - { - if ($this->collTaxRuleCountrys === null) { - $this->initTaxRuleCountrys(); - $this->collTaxRuleCountrysPartial = true; - } - if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddTaxRuleCountry($l); - } - - return $this; - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. - */ - protected function doAddTaxRuleCountry($taxRuleCountry) - { - $this->collTaxRuleCountrys[]= $taxRuleCountry; - $taxRuleCountry->setCountry($this); - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. - * @return Country The current object (for fluent API support) - */ - public function removeTaxRuleCountry($taxRuleCountry) - { - if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) { - $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry)); - if (null === $this->taxRuleCountrysScheduledForDeletion) { - $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys; - $this->taxRuleCountrysScheduledForDeletion->clear(); - } - $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; - $taxRuleCountry->setCountry(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Country is new, it will return - * an empty collection; or if this Country has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Country. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Tax', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Country is new, it will return - * an empty collection; or if this Country has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Country. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinTaxRule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('TaxRule', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - /** - * Clears out the collCountryI18ns 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 Country The current object (for fluent API support) - * @see addCountryI18ns() - */ - public function clearCountryI18ns() - { - $this->collCountryI18ns = null; // important to set this to null since that means it is uninitialized - $this->collCountryI18nsPartial = null; - - return $this; - } - - /** - * reset is the collCountryI18ns collection loaded partially - * - * @return void - */ - public function resetPartialCountryI18ns($v = true) - { - $this->collCountryI18nsPartial = $v; - } - - /** - * Initializes the collCountryI18ns collection. - * - * By default this just sets the collCountryI18ns collection to an empty array (like clearcollCountryI18ns()); - * 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 initCountryI18ns($overrideExisting = true) - { - if (null !== $this->collCountryI18ns && !$overrideExisting) { - return; - } - $this->collCountryI18ns = new PropelObjectCollection(); - $this->collCountryI18ns->setModel('CountryI18n'); - } - - /** - * Gets an array of CountryI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Country is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CountryI18n[] List of CountryI18n objects - * @throws PropelException - */ - public function getCountryI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCountryI18nsPartial && !$this->isNew(); - if (null === $this->collCountryI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCountryI18ns) { - // return empty collection - $this->initCountryI18ns(); - } else { - $collCountryI18ns = CountryI18nQuery::create(null, $criteria) - ->filterByCountry($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCountryI18nsPartial && count($collCountryI18ns)) { - $this->initCountryI18ns(false); - - foreach($collCountryI18ns as $obj) { - if (false == $this->collCountryI18ns->contains($obj)) { - $this->collCountryI18ns->append($obj); - } - } - - $this->collCountryI18nsPartial = true; - } - - $collCountryI18ns->getInternalIterator()->rewind(); - return $collCountryI18ns; - } - - if($partial && $this->collCountryI18ns) { - foreach($this->collCountryI18ns as $obj) { - if($obj->isNew()) { - $collCountryI18ns[] = $obj; - } - } - } - - $this->collCountryI18ns = $collCountryI18ns; - $this->collCountryI18nsPartial = false; - } - } - - return $this->collCountryI18ns; - } - - /** - * Sets a collection of CountryI18n 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 $countryI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Country The current object (for fluent API support) - */ - public function setCountryI18ns(PropelCollection $countryI18ns, PropelPDO $con = null) - { - $countryI18nsToDelete = $this->getCountryI18ns(new Criteria(), $con)->diff($countryI18ns); - - $this->countryI18nsScheduledForDeletion = unserialize(serialize($countryI18nsToDelete)); - - foreach ($countryI18nsToDelete as $countryI18nRemoved) { - $countryI18nRemoved->setCountry(null); - } - - $this->collCountryI18ns = null; - foreach ($countryI18ns as $countryI18n) { - $this->addCountryI18n($countryI18n); - } - - $this->collCountryI18ns = $countryI18ns; - $this->collCountryI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related CountryI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CountryI18n objects. - * @throws PropelException - */ - public function countCountryI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCountryI18nsPartial && !$this->isNew(); - if (null === $this->collCountryI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCountryI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCountryI18ns()); - } - $query = CountryI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCountry($this) - ->count($con); - } - - return count($this->collCountryI18ns); - } - - /** - * Method called to associate a CountryI18n object to this object - * through the CountryI18n foreign key attribute. - * - * @param CountryI18n $l CountryI18n - * @return Country The current object (for fluent API support) - */ - public function addCountryI18n(CountryI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collCountryI18ns === null) { - $this->initCountryI18ns(); - $this->collCountryI18nsPartial = true; - } - if (!in_array($l, $this->collCountryI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCountryI18n($l); - } - - return $this; - } - - /** - * @param CountryI18n $countryI18n The countryI18n object to add. - */ - protected function doAddCountryI18n($countryI18n) - { - $this->collCountryI18ns[]= $countryI18n; - $countryI18n->setCountry($this); - } - - /** - * @param CountryI18n $countryI18n The countryI18n object to remove. - * @return Country The current object (for fluent API support) - */ - public function removeCountryI18n($countryI18n) - { - if ($this->getCountryI18ns()->contains($countryI18n)) { - $this->collCountryI18ns->remove($this->collCountryI18ns->search($countryI18n)); - if (null === $this->countryI18nsScheduledForDeletion) { - $this->countryI18nsScheduledForDeletion = clone $this->collCountryI18ns; - $this->countryI18nsScheduledForDeletion->clear(); - } - $this->countryI18nsScheduledForDeletion[]= clone $countryI18n; - $countryI18n->setCountry(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->area_id = null; - $this->isocode = null; - $this->isoalpha2 = null; - $this->isoalpha3 = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collTaxRuleCountrys) { - foreach ($this->collTaxRuleCountrys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCountryI18ns) { - foreach ($this->collCountryI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aArea instanceof Persistent) { - $this->aArea->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); - } - $this->collTaxRuleCountrys = null; - if ($this->collCountryI18ns instanceof PropelCollection) { - $this->collCountryI18ns->clearIterator(); - } - $this->collCountryI18ns = null; - $this->aArea = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CountryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Country The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CountryPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Country The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return CountryI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collCountryI18ns) { - foreach ($this->collCountryI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new CountryI18n(); - $translation->setLocale($locale); - } else { - $translation = CountryI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addCountryI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Country The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - CountryI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collCountryI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collCountryI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return CountryI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCountryI18n.php b/core/lib/Thelia/Model/om/BaseCountryI18n.php deleted file mode 100755 index eb0d82b80..000000000 --- a/core/lib/Thelia/Model/om/BaseCountryI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseCountryI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CountryI18nPeer::ID; - } - - if ($this->aCountry !== null && $this->aCountry->getId() !== $v) { - $this->aCountry = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = CountryI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = CountryI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = CountryI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = CountryI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return CountryI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = CountryI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = CountryI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CountryI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCountry !== null && $this->id !== $this->aCountry->getId()) { - $this->aCountry = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::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 = CountryI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCountry = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CountryI18nQuery::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(CountryI18nPeer::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); - CountryI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCountry !== null) { - if ($this->aCountry->isModified() || $this->aCountry->isNew()) { - $affectedRows += $this->aCountry->save($con); - } - $this->setCountry($this->aCountry); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CountryI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CountryI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(CountryI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(CountryI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(CountryI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(CountryI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `country_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCountry !== null) { - if (!$this->aCountry->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCountry->getValidationFailures()); - } - } - - - if (($retval = CountryI18nPeer::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 = CountryI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['CountryI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CountryI18n'][serialize($this->getPrimaryKey())] = true; - $keys = CountryI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCountry) { - $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CountryI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = CountryI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CountryI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(CountryI18nPeer::ID)) $criteria->add(CountryI18nPeer::ID, $this->id); - if ($this->isColumnModified(CountryI18nPeer::LOCALE)) $criteria->add(CountryI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(CountryI18nPeer::TITLE)) $criteria->add(CountryI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(CountryI18nPeer::DESCRIPTION)) $criteria->add(CountryI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(CountryI18nPeer::CHAPO)) $criteria->add(CountryI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(CountryI18nPeer::POSTSCRIPTUM)) $criteria->add(CountryI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(CountryI18nPeer::DATABASE_NAME); - $criteria->add(CountryI18nPeer::ID, $this->id); - $criteria->add(CountryI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 CountryI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 CountryI18n 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 CountryI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CountryI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Country object. - * - * @param Country $v - * @return CountryI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setCountry(Country $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aCountry = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Country object, it will not be re-added. - if ($v !== null) { - $v->addCountryI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Country object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Country The associated Country object. - * @throws PropelException - */ - public function getCountry(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCountry === null && ($this->id !== null) && $doQuery) { - $this->aCountry = CountryQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCountry->addCountryI18ns($this); - */ - } - - return $this->aCountry; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCountry instanceof Persistent) { - $this->aCountry->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCountry = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CountryI18nPeer::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/BaseCountryI18nPeer.php b/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php deleted file mode 100755 index bb9cc78ce..000000000 --- a/core/lib/Thelia/Model/om/BaseCountryI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (CountryI18nPeer::ID, CountryI18nPeer::LOCALE, CountryI18nPeer::TITLE, CountryI18nPeer::DESCRIPTION, CountryI18nPeer::CHAPO, CountryI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CountryI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (CountryI18nPeer::ID => 0, CountryI18nPeer::LOCALE => 1, CountryI18nPeer::TITLE => 2, CountryI18nPeer::DESCRIPTION => 3, CountryI18nPeer::CHAPO => 4, CountryI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CountryI18nPeer::getFieldNames($toType); - $key = isset(CountryI18nPeer::$fieldKeys[$fromType][$name]) ? CountryI18nPeer::$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(CountryI18nPeer::$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, CountryI18nPeer::$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 CountryI18nPeer::$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. CountryI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CountryI18nPeer::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(CountryI18nPeer::ID); - $criteria->addSelectColumn(CountryI18nPeer::LOCALE); - $criteria->addSelectColumn(CountryI18nPeer::TITLE); - $criteria->addSelectColumn(CountryI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(CountryI18nPeer::CHAPO); - $criteria->addSelectColumn(CountryI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(CountryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CountryI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::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 CountryI18n - * @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 = CountryI18nPeer::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 CountryI18nPeer::populateObjects(CountryI18nPeer::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 directly (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(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CountryI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CountryI18nPeer::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 CountryI18n $obj A CountryI18n 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->getLocale())); - } // if key === null - CountryI18nPeer::$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 CountryI18n 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 CountryI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 CountryI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CountryI18nPeer::$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 CountryI18n 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(CountryI18nPeer::$instances[$key])) { - return CountryI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CountryI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CountryI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to country_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CountryI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CountryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CountryI18nPeer::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; - CountryI18nPeer::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 (CountryI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CountryI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CountryI18nPeer::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 + CountryI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CountryI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CountryI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Country table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCountry(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CountryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CountryI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CountryI18nPeer::ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of CountryI18n objects pre-filled with their Country objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CountryI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CountryI18nPeer::DATABASE_NAME); - } - - CountryI18nPeer::addSelectColumns($criteria); - $startcol = CountryI18nPeer::NUM_HYDRATE_COLUMNS; - CountryPeer::addSelectColumns($criteria); - - $criteria->addJoin(CountryI18nPeer::ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CountryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CountryI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CountryI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CountryI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CountryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CountryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CountryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CountryI18n) to $obj2 (Country) - $obj2->addCountryI18n($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(CountryI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CountryI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CountryI18nPeer::ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of CountryI18n 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 CountryI18n 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(CountryI18nPeer::DATABASE_NAME); - } - - CountryI18nPeer::addSelectColumns($criteria); - $startcol2 = CountryI18nPeer::NUM_HYDRATE_COLUMNS; - - CountryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CountryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CountryI18nPeer::ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CountryI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CountryI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CountryI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CountryI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Country rows - - $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CountryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CountryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CountryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CountryI18n) to the collection in $obj2 (Country) - $obj2->addCountryI18n($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(CountryI18nPeer::DATABASE_NAME)->getTable(CountryI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCountryI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCountryI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CountryI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CountryI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CountryI18n or Criteria object. - * - * @param mixed $values Criteria or CountryI18n 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(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CountryI18n object - } - - - // Set the correct dbName - $criteria->setDbName(CountryI18nPeer::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 CountryI18n or Criteria object. - * - * @param mixed $values Criteria or CountryI18n 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(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CountryI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CountryI18nPeer::ID); - $value = $criteria->remove(CountryI18nPeer::ID); - if ($value) { - $selectCriteria->add(CountryI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CountryI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(CountryI18nPeer::LOCALE); - $value = $criteria->remove(CountryI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(CountryI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CountryI18nPeer::TABLE_NAME); - } - - } else { // $values is CountryI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CountryI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the country_i18n 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(CountryI18nPeer::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(CountryI18nPeer::TABLE_NAME, $con, CountryI18nPeer::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). - CountryI18nPeer::clearInstancePool(); - CountryI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CountryI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CountryI18n 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(CountryI18nPeer::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. - CountryI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CountryI18n) { // it's a model object - // invalidate the cache for this single object - CountryI18nPeer::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(CountryI18nPeer::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(CountryI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(CountryI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - CountryI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(CountryI18nPeer::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); - CountryI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CountryI18n 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 CountryI18n $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(CountryI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CountryI18nPeer::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(CountryI18nPeer::DATABASE_NAME, CountryI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return CountryI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = CountryI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CountryI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(CountryI18nPeer::DATABASE_NAME); - $criteria->add(CountryI18nPeer::ID, $id); - $criteria->add(CountryI18nPeer::LOCALE, $locale); - $v = CountryI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseCountryI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCountryI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php b/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php deleted file mode 100755 index ed1ff2f7a..000000000 --- a/core/lib/Thelia/Model/om/BaseCountryI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return CountryI18n|CountryI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CountryI18nPeer::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(CountryI18nPeer::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 CountryI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `country_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 CountryI18n(); - $obj->hydrate($row); - CountryI18nPeer::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 CountryI18n|CountryI18n[]|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|CountryI18n[]|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 CountryI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(CountryI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(CountryI18nPeer::LOCALE, $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 CountryI18nQuery 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(CountryI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(CountryI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByCountry() - * - * @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 CountryI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CountryI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CountryI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CountryI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 CountryI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Country object - * - * @param Country|PropelObjectCollection $country The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCountry($country, $comparison = null) - { - if ($country instanceof Country) { - return $this - ->addUsingAlias(CountryI18nPeer::ID, $country->getId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CountryI18nPeer::ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Country relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function joinCountry($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Country'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Country'); - } - - return $this; - } - - /** - * Use the Country relation Country object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query - */ - public function useCountryQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery'); - } - - /** - * Exclude object from result - * - * @param CountryI18n $countryI18n Object to remove from the list of results - * - * @return CountryI18nQuery The current query, for fluid interface - */ - public function prune($countryI18n = null) - { - if ($countryI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(CountryI18nPeer::ID), $countryI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(CountryI18nPeer::LOCALE), $countryI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCountryPeer.php b/core/lib/Thelia/Model/om/BaseCountryPeer.php deleted file mode 100755 index 8101527b5..000000000 --- a/core/lib/Thelia/Model/om/BaseCountryPeer.php +++ /dev/null @@ -1,1050 +0,0 @@ - array ('Id', 'AreaId', 'Isocode', 'Isoalpha2', 'Isoalpha3', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'areaId', 'isocode', 'isoalpha2', 'isoalpha3', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CountryPeer::ID, CountryPeer::AREA_ID, CountryPeer::ISOCODE, CountryPeer::ISOALPHA2, CountryPeer::ISOALPHA3, CountryPeer::CREATED_AT, CountryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'AREA_ID', 'ISOCODE', 'ISOALPHA2', 'ISOALPHA3', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'area_id', 'isocode', 'isoalpha2', 'isoalpha3', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CountryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AreaId' => 1, 'Isocode' => 2, 'Isoalpha2' => 3, 'Isoalpha3' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'areaId' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (CountryPeer::ID => 0, CountryPeer::AREA_ID => 1, CountryPeer::ISOCODE => 2, CountryPeer::ISOALPHA2 => 3, CountryPeer::ISOALPHA3 => 4, CountryPeer::CREATED_AT => 5, CountryPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'AREA_ID' => 1, 'ISOCODE' => 2, 'ISOALPHA2' => 3, 'ISOALPHA3' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'area_id' => 1, 'isocode' => 2, 'isoalpha2' => 3, 'isoalpha3' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CountryPeer::getFieldNames($toType); - $key = isset(CountryPeer::$fieldKeys[$fromType][$name]) ? CountryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CountryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CountryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CountryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CountryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CountryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CountryPeer::ID); - $criteria->addSelectColumn(CountryPeer::AREA_ID); - $criteria->addSelectColumn(CountryPeer::ISOCODE); - $criteria->addSelectColumn(CountryPeer::ISOALPHA2); - $criteria->addSelectColumn(CountryPeer::ISOALPHA3); - $criteria->addSelectColumn(CountryPeer::CREATED_AT); - $criteria->addSelectColumn(CountryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.area_id'); - $criteria->addSelectColumn($alias . '.isocode'); - $criteria->addSelectColumn($alias . '.isoalpha2'); - $criteria->addSelectColumn($alias . '.isoalpha3'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CountryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Country - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CountryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CountryPeer::populateObjects(CountryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CountryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Country $obj A Country object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CountryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Country object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Country) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Country object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CountryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Country Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CountryPeer::$instances[$key])) { - return CountryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CountryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CountryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to country - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in TaxRuleCountryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxRuleCountryPeer::clearInstancePool(); - // Invalidate objects in CountryI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CountryI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CountryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CountryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CountryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Country object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CountryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CountryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CountryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CountryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Area table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinArea(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Country objects pre-filled with their Area objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Country objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinArea(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CountryPeer::DATABASE_NAME); - } - - CountryPeer::addSelectColumns($criteria); - $startcol = CountryPeer::NUM_HYDRATE_COLUMNS; - AreaPeer::addSelectColumns($criteria); - - $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CountryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AreaPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AreaPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AreaPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Country) to $obj2 (Area) - $obj2->addCountry($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Country objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Country objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CountryPeer::DATABASE_NAME); - } - - CountryPeer::addSelectColumns($criteria); - $startcol2 = CountryPeer::NUM_HYDRATE_COLUMNS; - - AreaPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AreaPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CountryPeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CountryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Area rows - - $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AreaPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AreaPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AreaPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Country) to the collection in $obj2 (Area) - $obj2->addCountry($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CountryPeer::DATABASE_NAME)->getTable(CountryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCountryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCountryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CountryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CountryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Country or Criteria object. - * - * @param mixed $values Criteria or Country object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Country object - } - - - // Set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Country or Criteria object. - * - * @param mixed $values Criteria or Country object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CountryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CountryPeer::ID); - $value = $criteria->remove(CountryPeer::ID); - if ($value) { - $selectCriteria->add(CountryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CountryPeer::TABLE_NAME); - } - - } else { // $values is Country object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the country table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CountryPeer::TABLE_NAME, $con, CountryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CountryPeer::clearInstancePool(); - CountryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Country or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Country object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CountryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Country) { // it's a model object - // invalidate the cache for this single object - CountryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - $criteria->add(CountryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CountryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CountryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CountryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Country object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Country $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CountryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CountryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CountryPeer::DATABASE_NAME, CountryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Country - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CountryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - $criteria->add(CountryPeer::ID, $pk); - - $v = CountryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Country[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CountryPeer::DATABASE_NAME); - $criteria->add(CountryPeer::ID, $pks, Criteria::IN); - $objs = CountryPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCountryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCountryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCountryQuery.php b/core/lib/Thelia/Model/om/BaseCountryQuery.php deleted file mode 100755 index 24c22c0b7..000000000 --- a/core/lib/Thelia/Model/om/BaseCountryQuery.php +++ /dev/null @@ -1,889 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Country|Country[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CountryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Country A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Country A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `area_id`, `isocode`, `isoalpha2`, `isoalpha3`, `created_at`, `updated_at` FROM `country` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Country(); - $obj->hydrate($row); - CountryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Country|Country[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Country[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CountryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CountryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CountryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CountryPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the area_id column - * - * Example usage: - * - * $query->filterByAreaId(1234); // WHERE area_id = 1234 - * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) - * $query->filterByAreaId(array('min' => 12)); // WHERE area_id >= 12 - * $query->filterByAreaId(array('max' => 12)); // WHERE area_id <= 12 - * - * - * @see filterByArea() - * - * @param mixed $areaId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByAreaId($areaId = null, $comparison = null) - { - if (is_array($areaId)) { - $useMinMax = false; - if (isset($areaId['min'])) { - $this->addUsingAlias(CountryPeer::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($areaId['max'])) { - $this->addUsingAlias(CountryPeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CountryPeer::AREA_ID, $areaId, $comparison); - } - - /** - * Filter the query on the isocode column - * - * Example usage: - * - * $query->filterByIsocode('fooValue'); // WHERE isocode = 'fooValue' - * $query->filterByIsocode('%fooValue%'); // WHERE isocode LIKE '%fooValue%' - * - * - * @param string $isocode The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByIsocode($isocode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($isocode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $isocode)) { - $isocode = str_replace('*', '%', $isocode); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryPeer::ISOCODE, $isocode, $comparison); - } - - /** - * Filter the query on the isoalpha2 column - * - * Example usage: - * - * $query->filterByIsoalpha2('fooValue'); // WHERE isoalpha2 = 'fooValue' - * $query->filterByIsoalpha2('%fooValue%'); // WHERE isoalpha2 LIKE '%fooValue%' - * - * - * @param string $isoalpha2 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByIsoalpha2($isoalpha2 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($isoalpha2)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $isoalpha2)) { - $isoalpha2 = str_replace('*', '%', $isoalpha2); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryPeer::ISOALPHA2, $isoalpha2, $comparison); - } - - /** - * Filter the query on the isoalpha3 column - * - * Example usage: - * - * $query->filterByIsoalpha3('fooValue'); // WHERE isoalpha3 = 'fooValue' - * $query->filterByIsoalpha3('%fooValue%'); // WHERE isoalpha3 LIKE '%fooValue%' - * - * - * @param string $isoalpha3 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByIsoalpha3($isoalpha3 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($isoalpha3)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $isoalpha3)) { - $isoalpha3 = str_replace('*', '%', $isoalpha3); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CountryPeer::ISOALPHA3, $isoalpha3, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CountryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CountryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Area object - * - * @param Area|PropelObjectCollection $area The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByArea($area, $comparison = null) - { - if ($area instanceof Area) { - return $this - ->addUsingAlias(CountryPeer::AREA_ID, $area->getId(), $comparison); - } elseif ($area instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CountryPeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Area relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CountryQuery The current query, for fluid interface - */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Area'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Area'); - } - - return $this; - } - - /** - * Use the Area relation Area object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query - */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinArea($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); - } - - /** - * Filter the query by a related TaxRuleCountry object - * - * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) - { - if ($taxRuleCountry instanceof TaxRuleCountry) { - return $this - ->addUsingAlias(CountryPeer::ID, $taxRuleCountry->getCountryId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { - return $this - ->useTaxRuleCountryQuery() - ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRuleCountry relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CountryQuery The current query, for fluid interface - */ - public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRuleCountry'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRuleCountry'); - } - - return $this; - } - - /** - * Use the TaxRuleCountry relation TaxRuleCountry object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRuleCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); - } - - /** - * Filter the query by a related CountryI18n object - * - * @param CountryI18n|PropelObjectCollection $countryI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCountryI18n($countryI18n, $comparison = null) - { - if ($countryI18n instanceof CountryI18n) { - return $this - ->addUsingAlias(CountryPeer::ID, $countryI18n->getId(), $comparison); - } elseif ($countryI18n instanceof PropelObjectCollection) { - return $this - ->useCountryI18nQuery() - ->filterByPrimaryKeys($countryI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCountryI18n() only accepts arguments of type CountryI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CountryI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CountryQuery The current query, for fluid interface - */ - public function joinCountryI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CountryI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CountryI18n'); - } - - return $this; - } - - /** - * Use the CountryI18n relation CountryI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CountryI18nQuery A secondary query class using the current class as primary query - */ - public function useCountryI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCountryI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', '\Thelia\Model\CountryI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Country $country Object to remove from the list of results - * - * @return CountryQuery The current query, for fluid interface - */ - public function prune($country = null) - { - if ($country) { - $this->addUsingAlias(CountryPeer::ID, $country->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CountryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CountryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CountryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CountryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CountryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CountryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CountryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CountryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CountryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CountryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CountryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CountryPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CountryQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; - - return $this - ->joinCountryI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CountryQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('CountryI18n'); - $this->with['CountryI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CountryI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CountryI18n', 'Thelia\Model\CountryI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCoupon.php b/core/lib/Thelia/Model/om/BaseCoupon.php deleted file mode 100755 index 345437ab2..000000000 --- a/core/lib/Thelia/Model/om/BaseCoupon.php +++ /dev/null @@ -1,1736 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [action] column value. - * - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * Get the [value] column value. - * - * @return double - */ - public function getValue() - { - return $this->value; - } - - /** - * Get the [used] column value. - * - * @return int - */ - public function getUsed() - { - return $this->used; - } - - /** - * Get the [optionally formatted] temporal [available_since] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getAvailableSince($format = 'Y-m-d H:i:s') - { - if ($this->available_since === null) { - return null; - } - - if ($this->available_since === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - try { - $dt = new DateTime($this->available_since); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->available_since, true), $x); - } - - if ($format === null) { - // Because propel.useDateTimeClass is true, we return a DateTime object. - return $dt; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Get the [optionally formatted] temporal [date_limit] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getDateLimit($format = 'Y-m-d H:i:s') - { - if ($this->date_limit === null) { - return null; - } - - if ($this->date_limit === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - try { - $dt = new DateTime($this->date_limit); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->date_limit, true), $x); - } - - if ($format === null) { - // Because propel.useDateTimeClass is true, we return a DateTime object. - return $dt; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Get the [activate] column value. - * - * @return int - */ - public function getActivate() - { - return $this->activate; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CouponPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = CouponPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [action] column. - * - * @param string $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setAction($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->action !== $v) { - $this->action = $v; - $this->modifiedColumns[] = CouponPeer::ACTION; - } - - - return $this; - } // setAction() - - /** - * Set the value of [value] column. - * - * @param double $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setValue($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponPeer::VALUE; - } - - - return $this; - } // setValue() - - /** - * Set the value of [used] column. - * - * @param int $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setUsed($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->used !== $v) { - $this->used = $v; - $this->modifiedColumns[] = CouponPeer::USED; - } - - - return $this; - } // setUsed() - - /** - * Sets the value of [available_since] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Coupon The current object (for fluent API support) - */ - public function setAvailableSince($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->available_since !== null || $dt !== null) { - $currentDateAsString = ($this->available_since !== null && $tmpDt = new DateTime($this->available_since)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->available_since = $newDateAsString; - $this->modifiedColumns[] = CouponPeer::AVAILABLE_SINCE; - } - } // if either are not null - - - return $this; - } // setAvailableSince() - - /** - * Sets the value of [date_limit] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Coupon The current object (for fluent API support) - */ - public function setDateLimit($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->date_limit !== null || $dt !== null) { - $currentDateAsString = ($this->date_limit !== null && $tmpDt = new DateTime($this->date_limit)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->date_limit = $newDateAsString; - $this->modifiedColumns[] = CouponPeer::DATE_LIMIT; - } - } // if either are not null - - - return $this; - } // setDateLimit() - - /** - * Set the value of [activate] column. - * - * @param int $v new value - * @return Coupon The current object (for fluent API support) - */ - public function setActivate($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->activate !== $v) { - $this->activate = $v; - $this->modifiedColumns[] = CouponPeer::ACTIVATE; - } - - - return $this; - } // setActivate() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Coupon The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CouponPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Coupon The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CouponPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->action = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->value = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null; - $this->used = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->available_since = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->date_limit = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->activate = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null; - $this->created_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->updated_at = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = CouponPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Coupon object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CouponPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collCouponRules = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CouponQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CouponPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CouponPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CouponPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CouponPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->couponRulesScheduledForDeletion !== null) { - if (!$this->couponRulesScheduledForDeletion->isEmpty()) { - CouponRuleQuery::create() - ->filterByPrimaryKeys($this->couponRulesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->couponRulesScheduledForDeletion = null; - } - } - - if ($this->collCouponRules !== null) { - foreach ($this->collCouponRules as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CouponPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CouponPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CouponPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(CouponPeer::ACTION)) { - $modifiedColumns[':p' . $index++] = '`action`'; - } - if ($this->isColumnModified(CouponPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; - } - if ($this->isColumnModified(CouponPeer::USED)) { - $modifiedColumns[':p' . $index++] = '`used`'; - } - if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) { - $modifiedColumns[':p' . $index++] = '`available_since`'; - } - if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) { - $modifiedColumns[':p' . $index++] = '`date_limit`'; - } - if ($this->isColumnModified(CouponPeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`activate`'; - } - if ($this->isColumnModified(CouponPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CouponPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `coupon` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`action`': - $stmt->bindValue($identifier, $this->action, PDO::PARAM_STR); - break; - case '`value`': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); - break; - case '`used`': - $stmt->bindValue($identifier, $this->used, PDO::PARAM_INT); - break; - case '`available_since`': - $stmt->bindValue($identifier, $this->available_since, PDO::PARAM_STR); - break; - case '`date_limit`': - $stmt->bindValue($identifier, $this->date_limit, PDO::PARAM_STR); - break; - case '`activate`': - $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CouponPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCouponRules !== null) { - foreach ($this->collCouponRules as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getAction(); - break; - case 3: - return $this->getValue(); - break; - case 4: - return $this->getUsed(); - break; - case 5: - return $this->getAvailableSince(); - break; - case 6: - return $this->getDateLimit(); - break; - case 7: - return $this->getActivate(); - break; - case 8: - return $this->getCreatedAt(); - break; - case 9: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Coupon'][$this->getPrimaryKey()] = true; - $keys = CouponPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getAction(), - $keys[3] => $this->getValue(), - $keys[4] => $this->getUsed(), - $keys[5] => $this->getAvailableSince(), - $keys[6] => $this->getDateLimit(), - $keys[7] => $this->getActivate(), - $keys[8] => $this->getCreatedAt(), - $keys[9] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collCouponRules) { - $result['CouponRules'] = $this->collCouponRules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setAction($value); - break; - case 3: - $this->setValue($value); - break; - case 4: - $this->setUsed($value); - break; - case 5: - $this->setAvailableSince($value); - break; - case 6: - $this->setDateLimit($value); - break; - case 7: - $this->setActivate($value); - break; - case 8: - $this->setCreatedAt($value); - break; - case 9: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CouponPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAction($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUsed($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAvailableSince($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setDateLimit($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setActivate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - - if ($this->isColumnModified(CouponPeer::ID)) $criteria->add(CouponPeer::ID, $this->id); - if ($this->isColumnModified(CouponPeer::CODE)) $criteria->add(CouponPeer::CODE, $this->code); - if ($this->isColumnModified(CouponPeer::ACTION)) $criteria->add(CouponPeer::ACTION, $this->action); - if ($this->isColumnModified(CouponPeer::VALUE)) $criteria->add(CouponPeer::VALUE, $this->value); - if ($this->isColumnModified(CouponPeer::USED)) $criteria->add(CouponPeer::USED, $this->used); - if ($this->isColumnModified(CouponPeer::AVAILABLE_SINCE)) $criteria->add(CouponPeer::AVAILABLE_SINCE, $this->available_since); - if ($this->isColumnModified(CouponPeer::DATE_LIMIT)) $criteria->add(CouponPeer::DATE_LIMIT, $this->date_limit); - if ($this->isColumnModified(CouponPeer::ACTIVATE)) $criteria->add(CouponPeer::ACTIVATE, $this->activate); - if ($this->isColumnModified(CouponPeer::CREATED_AT)) $criteria->add(CouponPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CouponPeer::UPDATED_AT)) $criteria->add(CouponPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - $criteria->add(CouponPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Coupon (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setAction($this->getAction()); - $copyObj->setValue($this->getValue()); - $copyObj->setUsed($this->getUsed()); - $copyObj->setAvailableSince($this->getAvailableSince()); - $copyObj->setDateLimit($this->getDateLimit()); - $copyObj->setActivate($this->getActivate()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getCouponRules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCouponRule($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Coupon Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CouponPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CouponPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('CouponRule' == $relationName) { - $this->initCouponRules(); - } - } - - /** - * Clears out the collCouponRules collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Coupon The current object (for fluent API support) - * @see addCouponRules() - */ - public function clearCouponRules() - { - $this->collCouponRules = null; // important to set this to null since that means it is uninitialized - $this->collCouponRulesPartial = null; - - return $this; - } - - /** - * reset is the collCouponRules collection loaded partially - * - * @return void - */ - public function resetPartialCouponRules($v = true) - { - $this->collCouponRulesPartial = $v; - } - - /** - * Initializes the collCouponRules collection. - * - * By default this just sets the collCouponRules collection to an empty array (like clearcollCouponRules()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCouponRules($overrideExisting = true) - { - if (null !== $this->collCouponRules && !$overrideExisting) { - return; - } - $this->collCouponRules = new PropelObjectCollection(); - $this->collCouponRules->setModel('CouponRule'); - } - - /** - * Gets an array of CouponRule objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Coupon is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CouponRule[] List of CouponRule objects - * @throws PropelException - */ - public function getCouponRules($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { - // return empty collection - $this->initCouponRules(); - } else { - $collCouponRules = CouponRuleQuery::create(null, $criteria) - ->filterByCoupon($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCouponRulesPartial && count($collCouponRules)) { - $this->initCouponRules(false); - - foreach($collCouponRules as $obj) { - if (false == $this->collCouponRules->contains($obj)) { - $this->collCouponRules->append($obj); - } - } - - $this->collCouponRulesPartial = true; - } - - $collCouponRules->getInternalIterator()->rewind(); - return $collCouponRules; - } - - if($partial && $this->collCouponRules) { - foreach($this->collCouponRules as $obj) { - if($obj->isNew()) { - $collCouponRules[] = $obj; - } - } - } - - $this->collCouponRules = $collCouponRules; - $this->collCouponRulesPartial = false; - } - } - - return $this->collCouponRules; - } - - /** - * Sets a collection of CouponRule objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $couponRules A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Coupon The current object (for fluent API support) - */ - public function setCouponRules(PropelCollection $couponRules, PropelPDO $con = null) - { - $couponRulesToDelete = $this->getCouponRules(new Criteria(), $con)->diff($couponRules); - - $this->couponRulesScheduledForDeletion = unserialize(serialize($couponRulesToDelete)); - - foreach ($couponRulesToDelete as $couponRuleRemoved) { - $couponRuleRemoved->setCoupon(null); - } - - $this->collCouponRules = null; - foreach ($couponRules as $couponRule) { - $this->addCouponRule($couponRule); - } - - $this->collCouponRules = $couponRules; - $this->collCouponRulesPartial = false; - - return $this; - } - - /** - * Returns the number of related CouponRule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CouponRule objects. - * @throws PropelException - */ - public function countCouponRules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCouponRulesPartial && !$this->isNew(); - if (null === $this->collCouponRules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponRules) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCouponRules()); - } - $query = CouponRuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCoupon($this) - ->count($con); - } - - return count($this->collCouponRules); - } - - /** - * Method called to associate a CouponRule object to this object - * through the CouponRule foreign key attribute. - * - * @param CouponRule $l CouponRule - * @return Coupon The current object (for fluent API support) - */ - public function addCouponRule(CouponRule $l) - { - if ($this->collCouponRules === null) { - $this->initCouponRules(); - $this->collCouponRulesPartial = true; - } - if (!in_array($l, $this->collCouponRules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCouponRule($l); - } - - return $this; - } - - /** - * @param CouponRule $couponRule The couponRule object to add. - */ - protected function doAddCouponRule($couponRule) - { - $this->collCouponRules[]= $couponRule; - $couponRule->setCoupon($this); - } - - /** - * @param CouponRule $couponRule The couponRule object to remove. - * @return Coupon The current object (for fluent API support) - */ - public function removeCouponRule($couponRule) - { - if ($this->getCouponRules()->contains($couponRule)) { - $this->collCouponRules->remove($this->collCouponRules->search($couponRule)); - if (null === $this->couponRulesScheduledForDeletion) { - $this->couponRulesScheduledForDeletion = clone $this->collCouponRules; - $this->couponRulesScheduledForDeletion->clear(); - } - $this->couponRulesScheduledForDeletion[]= clone $couponRule; - $couponRule->setCoupon(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->action = null; - $this->value = null; - $this->used = null; - $this->available_since = null; - $this->date_limit = null; - $this->activate = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collCouponRules) { - foreach ($this->collCouponRules as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collCouponRules instanceof PropelCollection) { - $this->collCouponRules->clearIterator(); - } - $this->collCouponRules = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CouponPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Coupon The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CouponPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCouponOrder.php b/core/lib/Thelia/Model/om/BaseCouponOrder.php deleted file mode 100755 index 5bdef9ed4..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponOrder.php +++ /dev/null @@ -1,1255 +0,0 @@ -id; - } - - /** - * Get the [order_id] column value. - * - * @return int - */ - public function getOrderId() - { - return $this->order_id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [value] column value. - * - * @return double - */ - public function getValue() - { - return $this->value; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CouponOrder The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CouponOrderPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [order_id] column. - * - * @param int $v new value - * @return CouponOrder The current object (for fluent API support) - */ - public function setOrderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->order_id !== $v) { - $this->order_id = $v; - $this->modifiedColumns[] = CouponOrderPeer::ORDER_ID; - } - - if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { - $this->aOrder = null; - } - - - return $this; - } // setOrderId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return CouponOrder The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = CouponOrderPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [value] column. - * - * @param double $v new value - * @return CouponOrder The current object (for fluent API support) - */ - public function setValue($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponOrderPeer::VALUE; - } - - - return $this; - } // setValue() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CouponOrder The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CouponOrderPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CouponOrder The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CouponOrderPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->order_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->value = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = CouponOrderPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CouponOrder object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { - $this->aOrder = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CouponOrderPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aOrder = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CouponOrderQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CouponOrderPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CouponOrderPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrder !== null) { - if ($this->aOrder->isModified() || $this->aOrder->isNew()) { - $affectedRows += $this->aOrder->save($con); - } - $this->setOrder($this->aOrder); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CouponOrderPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponOrderPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CouponOrderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CouponOrderPeer::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = '`order_id`'; - } - if ($this->isColumnModified(CouponOrderPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(CouponOrderPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; - } - if ($this->isColumnModified(CouponOrderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CouponOrderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `coupon_order` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`order_id`': - $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`value`': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrder !== null) { - if (!$this->aOrder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures()); - } - } - - - if (($retval = CouponOrderPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponOrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getOrderId(); - break; - case 2: - return $this->getCode(); - break; - case 3: - return $this->getValue(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CouponOrder'][$this->getPrimaryKey()] = true; - $keys = CouponOrderPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getOrderId(), - $keys[2] => $this->getCode(), - $keys[3] => $this->getValue(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aOrder) { - $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponOrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setOrderId($value); - break; - case 2: - $this->setCode($value); - break; - case 3: - $this->setValue($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CouponOrderPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setValue($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - - if ($this->isColumnModified(CouponOrderPeer::ID)) $criteria->add(CouponOrderPeer::ID, $this->id); - if ($this->isColumnModified(CouponOrderPeer::ORDER_ID)) $criteria->add(CouponOrderPeer::ORDER_ID, $this->order_id); - if ($this->isColumnModified(CouponOrderPeer::CODE)) $criteria->add(CouponOrderPeer::CODE, $this->code); - if ($this->isColumnModified(CouponOrderPeer::VALUE)) $criteria->add(CouponOrderPeer::VALUE, $this->value); - if ($this->isColumnModified(CouponOrderPeer::CREATED_AT)) $criteria->add(CouponOrderPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CouponOrderPeer::UPDATED_AT)) $criteria->add(CouponOrderPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - $criteria->add(CouponOrderPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of CouponOrder (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setOrderId($this->getOrderId()); - $copyObj->setCode($this->getCode()); - $copyObj->setValue($this->getValue()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CouponOrder Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CouponOrderPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CouponOrderPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Order object. - * - * @param Order $v - * @return CouponOrder The current object (for fluent API support) - * @throws PropelException - */ - public function setOrder(Order $v = null) - { - if ($v === null) { - $this->setOrderId(NULL); - } else { - $this->setOrderId($v->getId()); - } - - $this->aOrder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Order object, it will not be re-added. - if ($v !== null) { - $v->addCouponOrder($this); - } - - - return $this; - } - - - /** - * Get the associated Order object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Order The associated Order object. - * @throws PropelException - */ - public function getOrder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrder === null && ($this->order_id !== null) && $doQuery) { - $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrder->addCouponOrders($this); - */ - } - - return $this->aOrder; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->order_id = null; - $this->code = null; - $this->value = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aOrder instanceof Persistent) { - $this->aOrder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aOrder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CouponOrderPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return CouponOrder The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CouponOrderPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php b/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php deleted file mode 100755 index 7935f735e..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponOrderPeer.php +++ /dev/null @@ -1,1034 +0,0 @@ - array ('Id', 'OrderId', 'Code', 'Value', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderId', 'code', 'value', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CouponOrderPeer::ID, CouponOrderPeer::ORDER_ID, CouponOrderPeer::CODE, CouponOrderPeer::VALUE, CouponOrderPeer::CREATED_AT, CouponOrderPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_ID', 'CODE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'order_id', 'code', 'value', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CouponOrderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderId' => 1, 'Code' => 2, 'Value' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderId' => 1, 'code' => 2, 'value' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (CouponOrderPeer::ID => 0, CouponOrderPeer::ORDER_ID => 1, CouponOrderPeer::CODE => 2, CouponOrderPeer::VALUE => 3, CouponOrderPeer::CREATED_AT => 4, CouponOrderPeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_ID' => 1, 'CODE' => 2, 'VALUE' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_id' => 1, 'code' => 2, 'value' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CouponOrderPeer::getFieldNames($toType); - $key = isset(CouponOrderPeer::$fieldKeys[$fromType][$name]) ? CouponOrderPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponOrderPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CouponOrderPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CouponOrderPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CouponOrderPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CouponOrderPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CouponOrderPeer::ID); - $criteria->addSelectColumn(CouponOrderPeer::ORDER_ID); - $criteria->addSelectColumn(CouponOrderPeer::CODE); - $criteria->addSelectColumn(CouponOrderPeer::VALUE); - $criteria->addSelectColumn(CouponOrderPeer::CREATED_AT); - $criteria->addSelectColumn(CouponOrderPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.order_id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.value'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponOrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return CouponOrder - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CouponOrderPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CouponOrderPeer::populateObjects(CouponOrderPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CouponOrderPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param CouponOrder $obj A CouponOrder object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CouponOrderPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A CouponOrder object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CouponOrder) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CouponOrder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CouponOrderPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return CouponOrder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CouponOrderPeer::$instances[$key])) { - return CouponOrderPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CouponOrderPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CouponOrderPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to coupon_order - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CouponOrderPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CouponOrderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CouponOrderPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (CouponOrder object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CouponOrderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CouponOrderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CouponOrderPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CouponOrderPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CouponOrderPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Order table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponOrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of CouponOrder objects pre-filled with their Order objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CouponOrder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - } - - CouponOrderPeer::addSelectColumns($criteria); - $startcol = CouponOrderPeer::NUM_HYDRATE_COLUMNS; - OrderPeer::addSelectColumns($criteria); - - $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CouponOrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CouponOrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CouponOrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CouponOrder) to $obj2 (Order) - $obj2->addCouponOrder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponOrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of CouponOrder objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CouponOrder objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - } - - CouponOrderPeer::addSelectColumns($criteria); - $startcol2 = CouponOrderPeer::NUM_HYDRATE_COLUMNS; - - OrderPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CouponOrderPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CouponOrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CouponOrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CouponOrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CouponOrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Order rows - - $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = OrderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - OrderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CouponOrder) to the collection in $obj2 (Order) - $obj2->addCouponOrder($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CouponOrderPeer::DATABASE_NAME)->getTable(CouponOrderPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCouponOrderPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCouponOrderPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CouponOrderTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CouponOrderPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CouponOrder or Criteria object. - * - * @param mixed $values Criteria or CouponOrder object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CouponOrder object - } - - if ($criteria->containsKey(CouponOrderPeer::ID) && $criteria->keyContainsValue(CouponOrderPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponOrderPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a CouponOrder or Criteria object. - * - * @param mixed $values Criteria or CouponOrder object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CouponOrderPeer::ID); - $value = $criteria->remove(CouponOrderPeer::ID); - if ($value) { - $selectCriteria->add(CouponOrderPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CouponOrderPeer::TABLE_NAME); - } - - } else { // $values is CouponOrder object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the coupon_order table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CouponOrderPeer::TABLE_NAME, $con, CouponOrderPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CouponOrderPeer::clearInstancePool(); - CouponOrderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CouponOrder or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CouponOrder object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CouponOrderPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CouponOrder) { // it's a model object - // invalidate the cache for this single object - CouponOrderPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - $criteria->add(CouponOrderPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CouponOrderPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CouponOrderPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CouponOrderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CouponOrder object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param CouponOrder $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CouponOrderPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CouponOrderPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CouponOrderPeer::DATABASE_NAME, CouponOrderPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CouponOrder - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CouponOrderPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - $criteria->add(CouponOrderPeer::ID, $pk); - - $v = CouponOrderPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return CouponOrder[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CouponOrderPeer::DATABASE_NAME); - $criteria->add(CouponOrderPeer::ID, $pks, Criteria::IN); - $objs = CouponOrderPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCouponOrderPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCouponOrderPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php b/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php deleted file mode 100755 index 5a6f86656..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponOrderQuery.php +++ /dev/null @@ -1,654 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CouponOrderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CouponOrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponOrder A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponOrder A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `order_id`, `code`, `value`, `created_at`, `updated_at` FROM `coupon_order` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CouponOrder(); - $obj->hydrate($row); - CouponOrderPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponOrder|CouponOrder[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|CouponOrder[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CouponOrderPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CouponOrderPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CouponOrderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CouponOrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponOrderPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the order_id column - * - * Example usage: - * - * $query->filterByOrderId(1234); // WHERE order_id = 1234 - * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) - * $query->filterByOrderId(array('min' => 12)); // WHERE order_id >= 12 - * $query->filterByOrderId(array('max' => 12)); // WHERE order_id <= 12 - * - * - * @see filterByOrder() - * - * @param mixed $orderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByOrderId($orderId = null, $comparison = null) - { - if (is_array($orderId)) { - $useMinMax = false; - if (isset($orderId['min'])) { - $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($orderId['max'])) { - $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponOrderPeer::ORDER_ID, $orderId, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponOrderPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the value column - * - * Example usage: - * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 - * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 - * - * - * @param mixed $value The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByValue($value = null, $comparison = null) - { - if (is_array($value)) { - $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponOrderPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($value['max'])) { - $this->addUsingAlias(CouponOrderPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponOrderPeer::VALUE, $value, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponOrderPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponOrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->getId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CouponOrderPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Exclude object from result - * - * @param CouponOrder $couponOrder Object to remove from the list of results - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function prune($couponOrder = null) - { - if ($couponOrder) { - $this->addUsingAlias(CouponOrderPeer::ID, $couponOrder->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CouponOrderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CouponOrderPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CouponOrderPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CouponOrderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CouponOrderPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CouponOrderQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CouponOrderPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseCouponPeer.php b/core/lib/Thelia/Model/om/BaseCouponPeer.php deleted file mode 100755 index 4af0f4e3d..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponPeer.php +++ /dev/null @@ -1,819 +0,0 @@ - array ('Id', 'Code', 'Action', 'Value', 'Used', 'AvailableSince', 'DateLimit', 'Activate', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'action', 'value', 'used', 'availableSince', 'dateLimit', 'activate', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CouponPeer::ID, CouponPeer::CODE, CouponPeer::ACTION, CouponPeer::VALUE, CouponPeer::USED, CouponPeer::AVAILABLE_SINCE, CouponPeer::DATE_LIMIT, CouponPeer::ACTIVATE, CouponPeer::CREATED_AT, CouponPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'ACTION', 'VALUE', 'USED', 'AVAILABLE_SINCE', 'DATE_LIMIT', 'ACTIVATE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'action', 'value', 'used', 'available_since', 'date_limit', 'activate', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CouponPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Action' => 2, 'Value' => 3, 'Used' => 4, 'AvailableSince' => 5, 'DateLimit' => 6, 'Activate' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'availableSince' => 5, 'dateLimit' => 6, 'activate' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), - BasePeer::TYPE_COLNAME => array (CouponPeer::ID => 0, CouponPeer::CODE => 1, CouponPeer::ACTION => 2, CouponPeer::VALUE => 3, CouponPeer::USED => 4, CouponPeer::AVAILABLE_SINCE => 5, CouponPeer::DATE_LIMIT => 6, CouponPeer::ACTIVATE => 7, CouponPeer::CREATED_AT => 8, CouponPeer::UPDATED_AT => 9, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'ACTION' => 2, 'VALUE' => 3, 'USED' => 4, 'AVAILABLE_SINCE' => 5, 'DATE_LIMIT' => 6, 'ACTIVATE' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'action' => 2, 'value' => 3, 'used' => 4, 'available_since' => 5, 'date_limit' => 6, 'activate' => 7, 'created_at' => 8, 'updated_at' => 9, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CouponPeer::getFieldNames($toType); - $key = isset(CouponPeer::$fieldKeys[$fromType][$name]) ? CouponPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CouponPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CouponPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CouponPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CouponPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CouponPeer::ID); - $criteria->addSelectColumn(CouponPeer::CODE); - $criteria->addSelectColumn(CouponPeer::ACTION); - $criteria->addSelectColumn(CouponPeer::VALUE); - $criteria->addSelectColumn(CouponPeer::USED); - $criteria->addSelectColumn(CouponPeer::AVAILABLE_SINCE); - $criteria->addSelectColumn(CouponPeer::DATE_LIMIT); - $criteria->addSelectColumn(CouponPeer::ACTIVATE); - $criteria->addSelectColumn(CouponPeer::CREATED_AT); - $criteria->addSelectColumn(CouponPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.action'); - $criteria->addSelectColumn($alias . '.value'); - $criteria->addSelectColumn($alias . '.used'); - $criteria->addSelectColumn($alias . '.available_since'); - $criteria->addSelectColumn($alias . '.date_limit'); - $criteria->addSelectColumn($alias . '.activate'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CouponPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Coupon - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CouponPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CouponPeer::populateObjects(CouponPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CouponPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CouponPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Coupon $obj A Coupon object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CouponPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Coupon object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Coupon) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Coupon object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CouponPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Coupon Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CouponPeer::$instances[$key])) { - return CouponPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CouponPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CouponPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to coupon - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CouponRulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CouponRulePeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CouponPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CouponPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CouponPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Coupon object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CouponPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CouponPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CouponPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CouponPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CouponPeer::DATABASE_NAME)->getTable(CouponPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCouponPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCouponPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CouponTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CouponPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Coupon or Criteria object. - * - * @param mixed $values Criteria or Coupon object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Coupon object - } - - if ($criteria->containsKey(CouponPeer::ID) && $criteria->keyContainsValue(CouponPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CouponPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Coupon or Criteria object. - * - * @param mixed $values Criteria or Coupon object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CouponPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CouponPeer::ID); - $value = $criteria->remove(CouponPeer::ID); - if ($value) { - $selectCriteria->add(CouponPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CouponPeer::TABLE_NAME); - } - - } else { // $values is Coupon object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CouponPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the coupon table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CouponPeer::TABLE_NAME, $con, CouponPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CouponPeer::clearInstancePool(); - CouponPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Coupon or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Coupon object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CouponPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Coupon) { // it's a model object - // invalidate the cache for this single object - CouponPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - $criteria->add(CouponPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CouponPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CouponPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CouponPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Coupon object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Coupon $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CouponPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CouponPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CouponPeer::DATABASE_NAME, CouponPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Coupon - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CouponPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - $criteria->add(CouponPeer::ID, $pk); - - $v = CouponPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Coupon[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CouponPeer::DATABASE_NAME); - $criteria->add(CouponPeer::ID, $pks, Criteria::IN); - $objs = CouponPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCouponPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCouponPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCouponQuery.php b/core/lib/Thelia/Model/om/BaseCouponQuery.php deleted file mode 100755 index 4780154be..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponQuery.php +++ /dev/null @@ -1,823 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CouponPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CouponPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Coupon A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Coupon A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `action`, `value`, `used`, `available_since`, `date_limit`, `activate`, `created_at`, `updated_at` FROM `coupon` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Coupon(); - $obj->hydrate($row); - CouponPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Coupon|Coupon[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Coupon[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CouponPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CouponPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CouponPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CouponPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the action column - * - * Example usage: - * - * $query->filterByAction('fooValue'); // WHERE action = 'fooValue' - * $query->filterByAction('%fooValue%'); // WHERE action LIKE '%fooValue%' - * - * - * @param string $action The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByAction($action = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($action)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $action)) { - $action = str_replace('*', '%', $action); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponPeer::ACTION, $action, $comparison); - } - - /** - * Filter the query on the value column - * - * Example usage: - * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 - * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 - * - * - * @param mixed $value The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByValue($value = null, $comparison = null) - { - if (is_array($value)) { - $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($value['max'])) { - $this->addUsingAlias(CouponPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::VALUE, $value, $comparison); - } - - /** - * Filter the query on the used column - * - * Example usage: - * - * $query->filterByUsed(1234); // WHERE used = 1234 - * $query->filterByUsed(array(12, 34)); // WHERE used IN (12, 34) - * $query->filterByUsed(array('min' => 12)); // WHERE used >= 12 - * $query->filterByUsed(array('max' => 12)); // WHERE used <= 12 - * - * - * @param mixed $used The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByUsed($used = null, $comparison = null) - { - if (is_array($used)) { - $useMinMax = false; - if (isset($used['min'])) { - $this->addUsingAlias(CouponPeer::USED, $used['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($used['max'])) { - $this->addUsingAlias(CouponPeer::USED, $used['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::USED, $used, $comparison); - } - - /** - * Filter the query on the available_since column - * - * Example usage: - * - * $query->filterByAvailableSince('2011-03-14'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince('now'); // WHERE available_since = '2011-03-14' - * $query->filterByAvailableSince(array('max' => 'yesterday')); // WHERE available_since > '2011-03-13' - * - * - * @param mixed $availableSince The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByAvailableSince($availableSince = null, $comparison = null) - { - if (is_array($availableSince)) { - $useMinMax = false; - if (isset($availableSince['min'])) { - $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($availableSince['max'])) { - $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::AVAILABLE_SINCE, $availableSince, $comparison); - } - - /** - * Filter the query on the date_limit column - * - * Example usage: - * - * $query->filterByDateLimit('2011-03-14'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit('now'); // WHERE date_limit = '2011-03-14' - * $query->filterByDateLimit(array('max' => 'yesterday')); // WHERE date_limit > '2011-03-13' - * - * - * @param mixed $dateLimit The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByDateLimit($dateLimit = null, $comparison = null) - { - if (is_array($dateLimit)) { - $useMinMax = false; - if (isset($dateLimit['min'])) { - $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($dateLimit['max'])) { - $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::DATE_LIMIT, $dateLimit, $comparison); - } - - /** - * Filter the query on the activate column - * - * Example usage: - * - * $query->filterByActivate(1234); // WHERE activate = 1234 - * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate >= 12 - * $query->filterByActivate(array('max' => 12)); // WHERE activate <= 12 - * - * - * @param mixed $activate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByActivate($activate = null, $comparison = null) - { - if (is_array($activate)) { - $useMinMax = false; - if (isset($activate['min'])) { - $this->addUsingAlias(CouponPeer::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($activate['max'])) { - $this->addUsingAlias(CouponPeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::ACTIVATE, $activate, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related CouponRule object - * - * @param CouponRule|PropelObjectCollection $couponRule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCouponRule($couponRule, $comparison = null) - { - if ($couponRule instanceof CouponRule) { - return $this - ->addUsingAlias(CouponPeer::ID, $couponRule->getCouponId(), $comparison); - } elseif ($couponRule instanceof PropelObjectCollection) { - return $this - ->useCouponRuleQuery() - ->filterByPrimaryKeys($couponRule->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCouponRule() only accepts arguments of type CouponRule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CouponRule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CouponQuery The current query, for fluid interface - */ - public function joinCouponRule($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CouponRule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CouponRule'); - } - - return $this; - } - - /** - * Use the CouponRule relation CouponRule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CouponRuleQuery A secondary query class using the current class as primary query - */ - public function useCouponRuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCouponRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CouponRule', '\Thelia\Model\CouponRuleQuery'); - } - - /** - * Exclude object from result - * - * @param Coupon $coupon Object to remove from the list of results - * - * @return CouponQuery The current query, for fluid interface - */ - public function prune($coupon = null) - { - if ($coupon) { - $this->addUsingAlias(CouponPeer::ID, $coupon->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CouponQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CouponPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CouponQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CouponPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CouponQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CouponPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CouponQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CouponPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CouponQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CouponPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CouponQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CouponPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseCouponRule.php b/core/lib/Thelia/Model/om/BaseCouponRule.php deleted file mode 100755 index 134a0f869..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponRule.php +++ /dev/null @@ -1,1310 +0,0 @@ -id; - } - - /** - * Get the [coupon_id] column value. - * - * @return int - */ - public function getCouponId() - { - return $this->coupon_id; - } - - /** - * Get the [controller] column value. - * - * @return string - */ - public function getController() - { - return $this->controller; - } - - /** - * Get the [operation] column value. - * - * @return string - */ - public function getOperation() - { - return $this->operation; - } - - /** - * Get the [value] column value. - * - * @return double - */ - public function getValue() - { - return $this->value; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CouponRule The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CouponRulePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [coupon_id] column. - * - * @param int $v new value - * @return CouponRule The current object (for fluent API support) - */ - public function setCouponId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->coupon_id !== $v) { - $this->coupon_id = $v; - $this->modifiedColumns[] = CouponRulePeer::COUPON_ID; - } - - if ($this->aCoupon !== null && $this->aCoupon->getId() !== $v) { - $this->aCoupon = null; - } - - - return $this; - } // setCouponId() - - /** - * Set the value of [controller] column. - * - * @param string $v new value - * @return CouponRule The current object (for fluent API support) - */ - public function setController($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->controller !== $v) { - $this->controller = $v; - $this->modifiedColumns[] = CouponRulePeer::CONTROLLER; - } - - - return $this; - } // setController() - - /** - * Set the value of [operation] column. - * - * @param string $v new value - * @return CouponRule The current object (for fluent API support) - */ - public function setOperation($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->operation !== $v) { - $this->operation = $v; - $this->modifiedColumns[] = CouponRulePeer::OPERATION; - } - - - return $this; - } // setOperation() - - /** - * Set the value of [value] column. - * - * @param double $v new value - * @return CouponRule The current object (for fluent API support) - */ - public function setValue($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = CouponRulePeer::VALUE; - } - - - return $this; - } // setValue() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CouponRule The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CouponRulePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CouponRule The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CouponRulePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->coupon_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->controller = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->operation = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->value = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = CouponRulePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CouponRule object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCoupon !== null && $this->coupon_id !== $this->aCoupon->getId()) { - $this->aCoupon = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CouponRulePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCoupon = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CouponRuleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CouponRulePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CouponRulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CouponRulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CouponRulePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCoupon !== null) { - if ($this->aCoupon->isModified() || $this->aCoupon->isNew()) { - $affectedRows += $this->aCoupon->save($con); - } - $this->setCoupon($this->aCoupon); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CouponRulePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CouponRulePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CouponRulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CouponRulePeer::COUPON_ID)) { - $modifiedColumns[':p' . $index++] = '`coupon_id`'; - } - if ($this->isColumnModified(CouponRulePeer::CONTROLLER)) { - $modifiedColumns[':p' . $index++] = '`controller`'; - } - if ($this->isColumnModified(CouponRulePeer::OPERATION)) { - $modifiedColumns[':p' . $index++] = '`operation`'; - } - if ($this->isColumnModified(CouponRulePeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; - } - if ($this->isColumnModified(CouponRulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CouponRulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `coupon_rule` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`coupon_id`': - $stmt->bindValue($identifier, $this->coupon_id, PDO::PARAM_INT); - break; - case '`controller`': - $stmt->bindValue($identifier, $this->controller, PDO::PARAM_STR); - break; - case '`operation`': - $stmt->bindValue($identifier, $this->operation, PDO::PARAM_STR); - break; - case '`value`': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCoupon !== null) { - if (!$this->aCoupon->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCoupon->getValidationFailures()); - } - } - - - if (($retval = CouponRulePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCouponId(); - break; - case 2: - return $this->getController(); - break; - case 3: - return $this->getOperation(); - break; - case 4: - return $this->getValue(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CouponRule'][$this->getPrimaryKey()] = true; - $keys = CouponRulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCouponId(), - $keys[2] => $this->getController(), - $keys[3] => $this->getOperation(), - $keys[4] => $this->getValue(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCoupon) { - $result['Coupon'] = $this->aCoupon->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CouponRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCouponId($value); - break; - case 2: - $this->setController($value); - break; - case 3: - $this->setOperation($value); - break; - case 4: - $this->setValue($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CouponRulePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCouponId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setController($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setOperation($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CouponRulePeer::DATABASE_NAME); - - if ($this->isColumnModified(CouponRulePeer::ID)) $criteria->add(CouponRulePeer::ID, $this->id); - if ($this->isColumnModified(CouponRulePeer::COUPON_ID)) $criteria->add(CouponRulePeer::COUPON_ID, $this->coupon_id); - if ($this->isColumnModified(CouponRulePeer::CONTROLLER)) $criteria->add(CouponRulePeer::CONTROLLER, $this->controller); - if ($this->isColumnModified(CouponRulePeer::OPERATION)) $criteria->add(CouponRulePeer::OPERATION, $this->operation); - if ($this->isColumnModified(CouponRulePeer::VALUE)) $criteria->add(CouponRulePeer::VALUE, $this->value); - if ($this->isColumnModified(CouponRulePeer::CREATED_AT)) $criteria->add(CouponRulePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CouponRulePeer::UPDATED_AT)) $criteria->add(CouponRulePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CouponRulePeer::DATABASE_NAME); - $criteria->add(CouponRulePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of CouponRule (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCouponId($this->getCouponId()); - $copyObj->setController($this->getController()); - $copyObj->setOperation($this->getOperation()); - $copyObj->setValue($this->getValue()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CouponRule Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CouponRulePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CouponRulePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Coupon object. - * - * @param Coupon $v - * @return CouponRule The current object (for fluent API support) - * @throws PropelException - */ - public function setCoupon(Coupon $v = null) - { - if ($v === null) { - $this->setCouponId(NULL); - } else { - $this->setCouponId($v->getId()); - } - - $this->aCoupon = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Coupon object, it will not be re-added. - if ($v !== null) { - $v->addCouponRule($this); - } - - - return $this; - } - - - /** - * Get the associated Coupon object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Coupon The associated Coupon object. - * @throws PropelException - */ - public function getCoupon(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCoupon === null && ($this->coupon_id !== null) && $doQuery) { - $this->aCoupon = CouponQuery::create()->findPk($this->coupon_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCoupon->addCouponRules($this); - */ - } - - return $this->aCoupon; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->coupon_id = null; - $this->controller = null; - $this->operation = null; - $this->value = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCoupon instanceof Persistent) { - $this->aCoupon->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCoupon = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CouponRulePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return CouponRule The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CouponRulePeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php b/core/lib/Thelia/Model/om/BaseCouponRulePeer.php deleted file mode 100755 index 061390aa0..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponRulePeer.php +++ /dev/null @@ -1,1039 +0,0 @@ - array ('Id', 'CouponId', 'Controller', 'Operation', 'Value', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'couponId', 'controller', 'operation', 'value', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CouponRulePeer::ID, CouponRulePeer::COUPON_ID, CouponRulePeer::CONTROLLER, CouponRulePeer::OPERATION, CouponRulePeer::VALUE, CouponRulePeer::CREATED_AT, CouponRulePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'COUPON_ID', 'CONTROLLER', 'OPERATION', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'coupon_id', 'controller', 'operation', 'value', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CouponRulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CouponId' => 1, 'Controller' => 2, 'Operation' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'couponId' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (CouponRulePeer::ID => 0, CouponRulePeer::COUPON_ID => 1, CouponRulePeer::CONTROLLER => 2, CouponRulePeer::OPERATION => 3, CouponRulePeer::VALUE => 4, CouponRulePeer::CREATED_AT => 5, CouponRulePeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'COUPON_ID' => 1, 'CONTROLLER' => 2, 'OPERATION' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'coupon_id' => 1, 'controller' => 2, 'operation' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CouponRulePeer::getFieldNames($toType); - $key = isset(CouponRulePeer::$fieldKeys[$fromType][$name]) ? CouponRulePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CouponRulePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CouponRulePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CouponRulePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CouponRulePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CouponRulePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CouponRulePeer::ID); - $criteria->addSelectColumn(CouponRulePeer::COUPON_ID); - $criteria->addSelectColumn(CouponRulePeer::CONTROLLER); - $criteria->addSelectColumn(CouponRulePeer::OPERATION); - $criteria->addSelectColumn(CouponRulePeer::VALUE); - $criteria->addSelectColumn(CouponRulePeer::CREATED_AT); - $criteria->addSelectColumn(CouponRulePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.coupon_id'); - $criteria->addSelectColumn($alias . '.controller'); - $criteria->addSelectColumn($alias . '.operation'); - $criteria->addSelectColumn($alias . '.value'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponRulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return CouponRule - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CouponRulePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CouponRulePeer::populateObjects(CouponRulePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CouponRulePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param CouponRule $obj A CouponRule object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CouponRulePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A CouponRule object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CouponRule) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CouponRule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CouponRulePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return CouponRule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CouponRulePeer::$instances[$key])) { - return CouponRulePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CouponRulePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CouponRulePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to coupon_rule - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CouponRulePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CouponRulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CouponRulePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (CouponRule object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CouponRulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CouponRulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CouponRulePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CouponRulePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CouponRulePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Coupon table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCoupon(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponRulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of CouponRule objects pre-filled with their Coupon objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CouponRule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCoupon(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - } - - CouponRulePeer::addSelectColumns($criteria); - $startcol = CouponRulePeer::NUM_HYDRATE_COLUMNS; - CouponPeer::addSelectColumns($criteria); - - $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CouponRulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CouponRulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CouponRulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CouponPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CouponPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CouponPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CouponRule) to $obj2 (Coupon) - $obj2->addCouponRule($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CouponRulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of CouponRule objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CouponRule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - } - - CouponRulePeer::addSelectColumns($criteria); - $startcol2 = CouponRulePeer::NUM_HYDRATE_COLUMNS; - - CouponPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CouponPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CouponRulePeer::COUPON_ID, CouponPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CouponRulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CouponRulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CouponRulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CouponRulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Coupon rows - - $key2 = CouponPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CouponPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CouponPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CouponPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CouponRule) to the collection in $obj2 (Coupon) - $obj2->addCouponRule($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CouponRulePeer::DATABASE_NAME)->getTable(CouponRulePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCouponRulePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCouponRulePeer::TABLE_NAME)) { - $dbMap->addTableObject(new CouponRuleTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CouponRulePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CouponRule or Criteria object. - * - * @param mixed $values Criteria or CouponRule object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CouponRule object - } - - if ($criteria->containsKey(CouponRulePeer::ID) && $criteria->keyContainsValue(CouponRulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CouponRulePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a CouponRule or Criteria object. - * - * @param mixed $values Criteria or CouponRule object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CouponRulePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CouponRulePeer::ID); - $value = $criteria->remove(CouponRulePeer::ID); - if ($value) { - $selectCriteria->add(CouponRulePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CouponRulePeer::TABLE_NAME); - } - - } else { // $values is CouponRule object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the coupon_rule table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CouponRulePeer::TABLE_NAME, $con, CouponRulePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CouponRulePeer::clearInstancePool(); - CouponRulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CouponRule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CouponRule object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CouponRulePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CouponRule) { // it's a model object - // invalidate the cache for this single object - CouponRulePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CouponRulePeer::DATABASE_NAME); - $criteria->add(CouponRulePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CouponRulePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CouponRulePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CouponRulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CouponRule object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param CouponRule $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CouponRulePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CouponRulePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CouponRulePeer::DATABASE_NAME, CouponRulePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CouponRule - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CouponRulePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CouponRulePeer::DATABASE_NAME); - $criteria->add(CouponRulePeer::ID, $pk); - - $v = CouponRulePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return CouponRule[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CouponRulePeer::DATABASE_NAME); - $criteria->add(CouponRulePeer::ID, $pks, Criteria::IN); - $objs = CouponRulePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCouponRulePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCouponRulePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php b/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php deleted file mode 100755 index f1cfc175c..000000000 --- a/core/lib/Thelia/Model/om/BaseCouponRuleQuery.php +++ /dev/null @@ -1,687 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CouponRulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CouponRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponRule A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponRule A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `coupon_id`, `controller`, `operation`, `value`, `created_at`, `updated_at` FROM `coupon_rule` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CouponRule(); - $obj->hydrate($row); - CouponRulePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CouponRule|CouponRule[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|CouponRule[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CouponRulePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CouponRulePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CouponRulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CouponRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponRulePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the coupon_id column - * - * Example usage: - * - * $query->filterByCouponId(1234); // WHERE coupon_id = 1234 - * $query->filterByCouponId(array(12, 34)); // WHERE coupon_id IN (12, 34) - * $query->filterByCouponId(array('min' => 12)); // WHERE coupon_id >= 12 - * $query->filterByCouponId(array('max' => 12)); // WHERE coupon_id <= 12 - * - * - * @see filterByCoupon() - * - * @param mixed $couponId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByCouponId($couponId = null, $comparison = null) - { - if (is_array($couponId)) { - $useMinMax = false; - if (isset($couponId['min'])) { - $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($couponId['max'])) { - $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponRulePeer::COUPON_ID, $couponId, $comparison); - } - - /** - * Filter the query on the controller column - * - * Example usage: - * - * $query->filterByController('fooValue'); // WHERE controller = 'fooValue' - * $query->filterByController('%fooValue%'); // WHERE controller LIKE '%fooValue%' - * - * - * @param string $controller The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByController($controller = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($controller)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $controller)) { - $controller = str_replace('*', '%', $controller); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponRulePeer::CONTROLLER, $controller, $comparison); - } - - /** - * Filter the query on the operation column - * - * Example usage: - * - * $query->filterByOperation('fooValue'); // WHERE operation = 'fooValue' - * $query->filterByOperation('%fooValue%'); // WHERE operation LIKE '%fooValue%' - * - * - * @param string $operation The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByOperation($operation = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($operation)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $operation)) { - $operation = str_replace('*', '%', $operation); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CouponRulePeer::OPERATION, $operation, $comparison); - } - - /** - * Filter the query on the value column - * - * Example usage: - * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 - * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 - * - * - * @param mixed $value The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByValue($value = null, $comparison = null) - { - if (is_array($value)) { - $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(CouponRulePeer::VALUE, $value['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($value['max'])) { - $this->addUsingAlias(CouponRulePeer::VALUE, $value['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponRulePeer::VALUE, $value, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponRulePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CouponRulePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Coupon object - * - * @param Coupon|PropelObjectCollection $coupon The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CouponRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCoupon($coupon, $comparison = null) - { - if ($coupon instanceof Coupon) { - return $this - ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->getId(), $comparison); - } elseif ($coupon instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CouponRulePeer::COUPON_ID, $coupon->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCoupon() only accepts arguments of type Coupon or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Coupon relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function joinCoupon($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Coupon'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Coupon'); - } - - return $this; - } - - /** - * Use the Coupon relation Coupon object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CouponQuery A secondary query class using the current class as primary query - */ - public function useCouponQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCoupon($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Coupon', '\Thelia\Model\CouponQuery'); - } - - /** - * Exclude object from result - * - * @param CouponRule $couponRule Object to remove from the list of results - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function prune($couponRule = null) - { - if ($couponRule) { - $this->addUsingAlias(CouponRulePeer::ID, $couponRule->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CouponRulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CouponRulePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CouponRulePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CouponRulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CouponRulePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CouponRuleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CouponRulePeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseCurrency.php b/core/lib/Thelia/Model/om/BaseCurrency.php deleted file mode 100755 index 137e18da3..000000000 --- a/core/lib/Thelia/Model/om/BaseCurrency.php +++ /dev/null @@ -1,1663 +0,0 @@ -id; - } - - /** - * Get the [name] column value. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [symbol] column value. - * - * @return string - */ - public function getSymbol() - { - return $this->symbol; - } - - /** - * Get the [rate] column value. - * - * @return double - */ - public function getRate() - { - return $this->rate; - } - - /** - * Get the [by_default] column value. - * - * @return int - */ - public function getByDefault() - { - return $this->by_default; - } - - /** - * 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Currency The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CurrencyPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [name] column. - * - * @param string $v new value - * @return Currency The current object (for fluent API support) - */ - public function setName($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->name !== $v) { - $this->name = $v; - $this->modifiedColumns[] = CurrencyPeer::NAME; - } - - - return $this; - } // setName() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Currency The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = CurrencyPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [symbol] column. - * - * @param string $v new value - * @return Currency The current object (for fluent API support) - */ - public function setSymbol($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->symbol !== $v) { - $this->symbol = $v; - $this->modifiedColumns[] = CurrencyPeer::SYMBOL; - } - - - return $this; - } // setSymbol() - - /** - * Set the value of [rate] column. - * - * @param double $v new value - * @return Currency The current object (for fluent API support) - */ - public function setRate($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->rate !== $v) { - $this->rate = $v; - $this->modifiedColumns[] = CurrencyPeer::RATE; - } - - - return $this; - } // setRate() - - /** - * Set the value of [by_default] column. - * - * @param int $v new value - * @return Currency The current object (for fluent API support) - */ - public function setByDefault($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = CurrencyPeer::BY_DEFAULT; - } - - - return $this; - } // setByDefault() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Currency The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CurrencyPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Currency The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CurrencyPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->symbol = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->rate = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; - $this->by_default = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = CurrencyPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Currency object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CurrencyPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collOrders = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CurrencyQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CurrencyPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CurrencyPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CurrencyPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->ordersScheduledForDeletion !== null) { - if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } - $this->ordersScheduledForDeletion = null; - } - } - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CurrencyPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CurrencyPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CurrencyPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CurrencyPeer::NAME)) { - $modifiedColumns[':p' . $index++] = '`name`'; - } - if ($this->isColumnModified(CurrencyPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(CurrencyPeer::SYMBOL)) { - $modifiedColumns[':p' . $index++] = '`symbol`'; - } - if ($this->isColumnModified(CurrencyPeer::RATE)) { - $modifiedColumns[':p' . $index++] = '`rate`'; - } - if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; - } - if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `currency` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`name`': - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`symbol`': - $stmt->bindValue($identifier, $this->symbol, PDO::PARAM_STR); - break; - case '`rate`': - $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); - break; - case '`by_default`': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CurrencyPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getName(); - break; - case 2: - return $this->getCode(); - break; - case 3: - return $this->getSymbol(); - break; - case 4: - return $this->getRate(); - break; - case 5: - return $this->getByDefault(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Currency'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Currency'][$this->getPrimaryKey()] = true; - $keys = CurrencyPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getName(), - $keys[2] => $this->getCode(), - $keys[3] => $this->getSymbol(), - $keys[4] => $this->getRate(), - $keys[5] => $this->getByDefault(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collOrders) { - $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CurrencyPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setName($value); - break; - case 2: - $this->setCode($value); - break; - case 3: - $this->setSymbol($value); - break; - case 4: - $this->setRate($value); - break; - case 5: - $this->setByDefault($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CurrencyPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setSymbol($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setRate($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - - if ($this->isColumnModified(CurrencyPeer::ID)) $criteria->add(CurrencyPeer::ID, $this->id); - if ($this->isColumnModified(CurrencyPeer::NAME)) $criteria->add(CurrencyPeer::NAME, $this->name); - if ($this->isColumnModified(CurrencyPeer::CODE)) $criteria->add(CurrencyPeer::CODE, $this->code); - if ($this->isColumnModified(CurrencyPeer::SYMBOL)) $criteria->add(CurrencyPeer::SYMBOL, $this->symbol); - if ($this->isColumnModified(CurrencyPeer::RATE)) $criteria->add(CurrencyPeer::RATE, $this->rate); - if ($this->isColumnModified(CurrencyPeer::BY_DEFAULT)) $criteria->add(CurrencyPeer::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(CurrencyPeer::CREATED_AT)) $criteria->add(CurrencyPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CurrencyPeer::UPDATED_AT)) $criteria->add(CurrencyPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - $criteria->add(CurrencyPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Currency (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setName($this->getName()); - $copyObj->setCode($this->getCode()); - $copyObj->setSymbol($this->getSymbol()); - $copyObj->setRate($this->getRate()); - $copyObj->setByDefault($this->getByDefault()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getOrders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrder($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Currency Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CurrencyPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CurrencyPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Order' == $relationName) { - $this->initOrders(); - } - } - - /** - * Clears out the collOrders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Currency The current object (for fluent API support) - * @see addOrders() - */ - public function clearOrders() - { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; - } - - /** - * reset is the collOrders collection loaded partially - * - * @return void - */ - public function resetPartialOrders($v = true) - { - $this->collOrdersPartial = $v; - } - - /** - * Initializes the collOrders collection. - * - * By default this just sets the collOrders collection to an empty array (like clearcollOrders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrders($overrideExisting = true) - { - if (null !== $this->collOrders && !$overrideExisting) { - return; - } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); - } - - /** - * Gets an array of Order objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Currency is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Order[] List of Order objects - * @throws PropelException - */ - public function getOrders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - // return empty collection - $this->initOrders(); - } else { - $collOrders = OrderQuery::create(null, $criteria) - ->filterByCurrency($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); - - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); - } - } - - $this->collOrdersPartial = true; - } - - $collOrders->getInternalIterator()->rewind(); - return $collOrders; - } - - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { - $collOrders[] = $obj; - } - } - } - - $this->collOrders = $collOrders; - $this->collOrdersPartial = false; - } - } - - return $this->collOrders; - } - - /** - * Sets a collection of Order objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $orders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Currency The current object (for fluent API support) - */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) - { - $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); - - foreach ($ordersToDelete as $orderRemoved) { - $orderRemoved->setCurrency(null); - } - - $this->collOrders = null; - foreach ($orders as $order) { - $this->addOrder($order); - } - - $this->collOrders = $orders; - $this->collOrdersPartial = false; - - return $this; - } - - /** - * Returns the number of related Order objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Order objects. - * @throws PropelException - */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCurrency($this) - ->count($con); - } - - return count($this->collOrders); - } - - /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. - * - * @param Order $l Order - * @return Currency The current object (for fluent API support) - */ - public function addOrder(Order $l) - { - if ($this->collOrders === null) { - $this->initOrders(); - $this->collOrdersPartial = true; - } - if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrder($l); - } - - return $this; - } - - /** - * @param Order $order The order object to add. - */ - protected function doAddOrder($order) - { - $this->collOrders[]= $order; - $order->setCurrency($this); - } - - /** - * @param Order $order The order object to remove. - * @return Currency The current object (for fluent API support) - */ - public function removeOrder($order) - { - if ($this->getOrders()->contains($order)) { - $this->collOrders->remove($this->collOrders->search($order)); - if (null === $this->ordersScheduledForDeletion) { - $this->ordersScheduledForDeletion = clone $this->collOrders; - $this->ordersScheduledForDeletion->clear(); - } - $this->ordersScheduledForDeletion[]= $order; - $order->setCurrency(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Currency is new, it will return - * an empty collection; or if this Currency has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Currency. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Currency is new, it will return - * an empty collection; or if this Currency has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Currency. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Currency is new, it will return - * an empty collection; or if this Currency has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Currency. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Currency is new, it will return - * an empty collection; or if this Currency has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Currency. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); - - return $this->getOrders($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->name = null; - $this->code = null; - $this->symbol = null; - $this->rate = null; - $this->by_default = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collOrders) { - foreach ($this->collOrders as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collOrders instanceof PropelCollection) { - $this->collOrders->clearIterator(); - } - $this->collOrders = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CurrencyPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Currency The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CurrencyPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php b/core/lib/Thelia/Model/om/BaseCurrencyPeer.php deleted file mode 100755 index 5da12afbb..000000000 --- a/core/lib/Thelia/Model/om/BaseCurrencyPeer.php +++ /dev/null @@ -1,809 +0,0 @@ - array ('Id', 'Name', 'Code', 'Symbol', 'Rate', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'byDefault', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID, CurrencyPeer::NAME, CurrencyPeer::CODE, CurrencyPeer::SYMBOL, CurrencyPeer::RATE, CurrencyPeer::BY_DEFAULT, CurrencyPeer::CREATED_AT, CurrencyPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'NAME', 'CODE', 'SYMBOL', 'RATE', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'code', 'symbol', 'rate', 'by_default', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CurrencyPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Code' => 2, 'Symbol' => 3, 'Rate' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (CurrencyPeer::ID => 0, CurrencyPeer::NAME => 1, CurrencyPeer::CODE => 2, CurrencyPeer::SYMBOL => 3, CurrencyPeer::RATE => 4, CurrencyPeer::BY_DEFAULT => 5, CurrencyPeer::CREATED_AT => 6, CurrencyPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'NAME' => 1, 'CODE' => 2, 'SYMBOL' => 3, 'RATE' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'code' => 2, 'symbol' => 3, 'rate' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CurrencyPeer::getFieldNames($toType); - $key = isset(CurrencyPeer::$fieldKeys[$fromType][$name]) ? CurrencyPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CurrencyPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CurrencyPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CurrencyPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CurrencyPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CurrencyPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CurrencyPeer::ID); - $criteria->addSelectColumn(CurrencyPeer::NAME); - $criteria->addSelectColumn(CurrencyPeer::CODE); - $criteria->addSelectColumn(CurrencyPeer::SYMBOL); - $criteria->addSelectColumn(CurrencyPeer::RATE); - $criteria->addSelectColumn(CurrencyPeer::BY_DEFAULT); - $criteria->addSelectColumn(CurrencyPeer::CREATED_AT); - $criteria->addSelectColumn(CurrencyPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.name'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.symbol'); - $criteria->addSelectColumn($alias . '.rate'); - $criteria->addSelectColumn($alias . '.by_default'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CurrencyPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CurrencyPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CurrencyPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Currency - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CurrencyPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CurrencyPeer::populateObjects(CurrencyPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CurrencyPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CurrencyPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Currency $obj A Currency object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CurrencyPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Currency object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Currency) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Currency object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CurrencyPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Currency Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CurrencyPeer::$instances[$key])) { - return CurrencyPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CurrencyPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CurrencyPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to currency - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in OrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CurrencyPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CurrencyPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CurrencyPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CurrencyPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Currency object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CurrencyPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CurrencyPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CurrencyPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CurrencyPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CurrencyPeer::DATABASE_NAME)->getTable(CurrencyPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCurrencyPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCurrencyPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CurrencyTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CurrencyPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Currency or Criteria object. - * - * @param mixed $values Criteria or Currency object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Currency object - } - - if ($criteria->containsKey(CurrencyPeer::ID) && $criteria->keyContainsValue(CurrencyPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CurrencyPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CurrencyPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Currency or Criteria object. - * - * @param mixed $values Criteria or Currency object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CurrencyPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CurrencyPeer::ID); - $value = $criteria->remove(CurrencyPeer::ID); - if ($value) { - $selectCriteria->add(CurrencyPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CurrencyPeer::TABLE_NAME); - } - - } else { // $values is Currency object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CurrencyPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the currency table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CurrencyPeer::TABLE_NAME, $con, CurrencyPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CurrencyPeer::clearInstancePool(); - CurrencyPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Currency or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Currency object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CurrencyPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Currency) { // it's a model object - // invalidate the cache for this single object - CurrencyPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - $criteria->add(CurrencyPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CurrencyPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CurrencyPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CurrencyPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Currency object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Currency $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CurrencyPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CurrencyPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CurrencyPeer::DATABASE_NAME, CurrencyPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Currency - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CurrencyPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - $criteria->add(CurrencyPeer::ID, $pk); - - $v = CurrencyPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Currency[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CurrencyPeer::DATABASE_NAME); - $criteria->add(CurrencyPeer::ID, $pks, Criteria::IN); - $objs = CurrencyPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCurrencyPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCurrencyPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php b/core/lib/Thelia/Model/om/BaseCurrencyQuery.php deleted file mode 100755 index 7c202ec84..000000000 --- a/core/lib/Thelia/Model/om/BaseCurrencyQuery.php +++ /dev/null @@ -1,716 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Currency|Currency[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CurrencyPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CurrencyPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Currency A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Currency A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `name`, `code`, `symbol`, `rate`, `by_default`, `created_at`, `updated_at` FROM `currency` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Currency(); - $obj->hydrate($row); - CurrencyPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Currency|Currency[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Currency[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CurrencyPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CurrencyPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CurrencyPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CurrencyPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the name column - * - * Example usage: - * - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' - * - * - * @param string $name The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByName($name = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($name)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $name)) { - $name = str_replace('*', '%', $name); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CurrencyPeer::NAME, $name, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CurrencyPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the symbol column - * - * Example usage: - * - * $query->filterBySymbol('fooValue'); // WHERE symbol = 'fooValue' - * $query->filterBySymbol('%fooValue%'); // WHERE symbol LIKE '%fooValue%' - * - * - * @param string $symbol The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterBySymbol($symbol = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($symbol)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $symbol)) { - $symbol = str_replace('*', '%', $symbol); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CurrencyPeer::SYMBOL, $symbol, $comparison); - } - - /** - * Filter the query on the rate column - * - * Example usage: - * - * $query->filterByRate(1234); // WHERE rate = 1234 - * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34) - * $query->filterByRate(array('min' => 12)); // WHERE rate >= 12 - * $query->filterByRate(array('max' => 12)); // WHERE rate <= 12 - * - * - * @param mixed $rate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByRate($rate = null, $comparison = null) - { - if (is_array($rate)) { - $useMinMax = false; - if (isset($rate['min'])) { - $this->addUsingAlias(CurrencyPeer::RATE, $rate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($rate['max'])) { - $this->addUsingAlias(CurrencyPeer::RATE, $rate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyPeer::RATE, $rate, $comparison); - } - - /** - * Filter the query on the by_default column - * - * Example usage: - * - * $query->filterByByDefault(1234); // WHERE by_default = 1234 - * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 - * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 - * - * - * @param mixed $byDefault The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByByDefault($byDefault = null, $comparison = null) - { - if (is_array($byDefault)) { - $useMinMax = false; - if (isset($byDefault['min'])) { - $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($byDefault['max'])) { - $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyPeer::BY_DEFAULT, $byDefault, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CurrencyPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CurrencyQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(CurrencyPeer::ID, $order->getCurrencyId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - return $this - ->useOrderQuery() - ->filterByPrimaryKeys($order->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Exclude object from result - * - * @param Currency $currency Object to remove from the list of results - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function prune($currency = null) - { - if ($currency) { - $this->addUsingAlias(CurrencyPeer::ID, $currency->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CurrencyPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CurrencyPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CurrencyPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CurrencyPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CurrencyPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CurrencyQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CurrencyPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseCustomer.php b/core/lib/Thelia/Model/om/BaseCustomer.php deleted file mode 100755 index 6935ed1ea..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomer.php +++ /dev/null @@ -1,2945 +0,0 @@ -id; - } - - /** - * Get the [ref] column value. - * - * @return string - */ - public function getRef() - { - return $this->ref; - } - - /** - * Get the [customer_title_id] column value. - * - * @return int - */ - public function getCustomerTitleId() - { - return $this->customer_title_id; - } - - /** - * Get the [company] column value. - * - * @return string - */ - public function getCompany() - { - return $this->company; - } - - /** - * Get the [firstname] column value. - * - * @return string - */ - public function getFirstname() - { - return $this->firstname; - } - - /** - * Get the [lastname] column value. - * - * @return string - */ - public function getLastname() - { - return $this->lastname; - } - - /** - * Get the [address1] column value. - * - * @return string - */ - public function getAddress1() - { - return $this->address1; - } - - /** - * Get the [address2] column value. - * - * @return string - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * Get the [address3] column value. - * - * @return string - */ - public function getAddress3() - { - return $this->address3; - } - - /** - * Get the [zipcode] column value. - * - * @return string - */ - public function getZipcode() - { - return $this->zipcode; - } - - /** - * Get the [city] column value. - * - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * Get the [country_id] column value. - * - * @return int - */ - public function getCountryId() - { - return $this->country_id; - } - - /** - * Get the [phone] column value. - * - * @return string - */ - public function getPhone() - { - return $this->phone; - } - - /** - * Get the [cellphone] column value. - * - * @return string - */ - public function getCellphone() - { - return $this->cellphone; - } - - /** - * Get the [email] column value. - * - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * Get the [password] column value. - * - * @return string - */ - public function getPassword() - { - return $this->password; - } - - /** - * Get the [algo] column value. - * - * @return string - */ - public function getAlgo() - { - return $this->algo; - } - - /** - * Get the [salt] column value. - * - * @return string - */ - public function getSalt() - { - return $this->salt; - } - - /** - * Get the [reseller] column value. - * - * @return int - */ - public function getReseller() - { - return $this->reseller; - } - - /** - * Get the [lang] column value. - * - * @return string - */ - public function getLang() - { - return $this->lang; - } - - /** - * Get the [sponsor] column value. - * - * @return string - */ - public function getSponsor() - { - return $this->sponsor; - } - - /** - * Get the [discount] column value. - * - * @return double - */ - public function getDiscount() - { - return $this->discount; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Customer The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CustomerPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = CustomerPeer::REF; - } - - - return $this; - } // setRef() - - /** - * Set the value of [customer_title_id] column. - * - * @param int $v new value - * @return Customer The current object (for fluent API support) - */ - public function setCustomerTitleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->customer_title_id !== $v) { - $this->customer_title_id = $v; - $this->modifiedColumns[] = CustomerPeer::CUSTOMER_TITLE_ID; - } - - if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { - $this->aCustomerTitle = null; - } - - - return $this; - } // setCustomerTitleId() - - /** - * Set the value of [company] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setCompany($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->company !== $v) { - $this->company = $v; - $this->modifiedColumns[] = CustomerPeer::COMPANY; - } - - - return $this; - } // setCompany() - - /** - * Set the value of [firstname] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setFirstname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->firstname !== $v) { - $this->firstname = $v; - $this->modifiedColumns[] = CustomerPeer::FIRSTNAME; - } - - - return $this; - } // setFirstname() - - /** - * Set the value of [lastname] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setLastname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lastname !== $v) { - $this->lastname = $v; - $this->modifiedColumns[] = CustomerPeer::LASTNAME; - } - - - return $this; - } // setLastname() - - /** - * Set the value of [address1] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setAddress1($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address1 !== $v) { - $this->address1 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS1; - } - - - return $this; - } // setAddress1() - - /** - * Set the value of [address2] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setAddress2($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address2 !== $v) { - $this->address2 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS2; - } - - - return $this; - } // setAddress2() - - /** - * Set the value of [address3] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setAddress3($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address3 !== $v) { - $this->address3 = $v; - $this->modifiedColumns[] = CustomerPeer::ADDRESS3; - } - - - return $this; - } // setAddress3() - - /** - * Set the value of [zipcode] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setZipcode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->zipcode !== $v) { - $this->zipcode = $v; - $this->modifiedColumns[] = CustomerPeer::ZIPCODE; - } - - - return $this; - } // setZipcode() - - /** - * Set the value of [city] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setCity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->city !== $v) { - $this->city = $v; - $this->modifiedColumns[] = CustomerPeer::CITY; - } - - - return $this; - } // setCity() - - /** - * Set the value of [country_id] column. - * - * @param int $v new value - * @return Customer The current object (for fluent API support) - */ - public function setCountryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->country_id !== $v) { - $this->country_id = $v; - $this->modifiedColumns[] = CustomerPeer::COUNTRY_ID; - } - - - return $this; - } // setCountryId() - - /** - * Set the value of [phone] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setPhone($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->phone !== $v) { - $this->phone = $v; - $this->modifiedColumns[] = CustomerPeer::PHONE; - } - - - return $this; - } // setPhone() - - /** - * Set the value of [cellphone] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setCellphone($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->cellphone !== $v) { - $this->cellphone = $v; - $this->modifiedColumns[] = CustomerPeer::CELLPHONE; - } - - - return $this; - } // setCellphone() - - /** - * Set the value of [email] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setEmail($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->email !== $v) { - $this->email = $v; - $this->modifiedColumns[] = CustomerPeer::EMAIL; - } - - - return $this; - } // setEmail() - - /** - * Set the value of [password] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setPassword($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->password !== $v) { - $this->password = $v; - $this->modifiedColumns[] = CustomerPeer::PASSWORD; - } - - - return $this; - } // setPassword() - - /** - * Set the value of [algo] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setAlgo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->algo !== $v) { - $this->algo = $v; - $this->modifiedColumns[] = CustomerPeer::ALGO; - } - - - return $this; - } // setAlgo() - - /** - * Set the value of [salt] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setSalt($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->salt !== $v) { - $this->salt = $v; - $this->modifiedColumns[] = CustomerPeer::SALT; - } - - - return $this; - } // setSalt() - - /** - * Set the value of [reseller] column. - * - * @param int $v new value - * @return Customer The current object (for fluent API support) - */ - public function setReseller($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->reseller !== $v) { - $this->reseller = $v; - $this->modifiedColumns[] = CustomerPeer::RESELLER; - } - - - return $this; - } // setReseller() - - /** - * Set the value of [lang] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setLang($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lang !== $v) { - $this->lang = $v; - $this->modifiedColumns[] = CustomerPeer::LANG; - } - - - return $this; - } // setLang() - - /** - * Set the value of [sponsor] column. - * - * @param string $v new value - * @return Customer The current object (for fluent API support) - */ - public function setSponsor($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->sponsor !== $v) { - $this->sponsor = $v; - $this->modifiedColumns[] = CustomerPeer::SPONSOR; - } - - - return $this; - } // setSponsor() - - /** - * Set the value of [discount] column. - * - * @param double $v new value - * @return Customer The current object (for fluent API support) - */ - public function setDiscount($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->discount !== $v) { - $this->discount = $v; - $this->modifiedColumns[] = CustomerPeer::DISCOUNT; - } - - - return $this; - } // setDiscount() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Customer The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CustomerPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Customer The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CustomerPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->customer_title_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->company = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->firstname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->lastname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->address1 = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->address2 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->address3 = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->zipcode = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->city = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->country_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; - $this->phone = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->cellphone = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->email = ($row[$startcol + 14] !== null) ? (string) $row[$startcol + 14] : null; - $this->password = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; - $this->algo = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; - $this->salt = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; - $this->reseller = ($row[$startcol + 18] !== null) ? (int) $row[$startcol + 18] : null; - $this->lang = ($row[$startcol + 19] !== null) ? (string) $row[$startcol + 19] : null; - $this->sponsor = ($row[$startcol + 20] !== null) ? (string) $row[$startcol + 20] : null; - $this->discount = ($row[$startcol + 21] !== null) ? (double) $row[$startcol + 21] : null; - $this->created_at = ($row[$startcol + 22] !== null) ? (string) $row[$startcol + 22] : null; - $this->updated_at = ($row[$startcol + 23] !== null) ? (string) $row[$startcol + 23] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 24; // 24 = CustomerPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Customer object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCustomerTitle !== null && $this->customer_title_id !== $this->aCustomerTitle->getId()) { - $this->aCustomerTitle = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CustomerPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCustomerTitle = null; - $this->collAddresss = null; - - $this->collOrders = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CustomerQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CustomerPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CustomerPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CustomerPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CustomerPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomerTitle !== null) { - if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) { - $affectedRows += $this->aCustomerTitle->save($con); - } - $this->setCustomerTitle($this->aCustomerTitle); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->addresssScheduledForDeletion !== null) { - if (!$this->addresssScheduledForDeletion->isEmpty()) { - AddressQuery::create() - ->filterByPrimaryKeys($this->addresssScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->addresssScheduledForDeletion = null; - } - } - - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->ordersScheduledForDeletion !== null) { - if (!$this->ordersScheduledForDeletion->isEmpty()) { - OrderQuery::create() - ->filterByPrimaryKeys($this->ordersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->ordersScheduledForDeletion = null; - } - } - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CustomerPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CustomerPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CustomerPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; - } - if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; - } - if ($this->isColumnModified(CustomerPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; - } - if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; - } - if ($this->isColumnModified(CustomerPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; - } - if ($this->isColumnModified(CustomerPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; - } - if ($this->isColumnModified(CustomerPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; - } - if ($this->isColumnModified(CustomerPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; - } - if ($this->isColumnModified(CustomerPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; - } - if ($this->isColumnModified(CustomerPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; - } - if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; - } - if ($this->isColumnModified(CustomerPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; - } - if ($this->isColumnModified(CustomerPeer::CELLPHONE)) { - $modifiedColumns[':p' . $index++] = '`cellphone`'; - } - if ($this->isColumnModified(CustomerPeer::EMAIL)) { - $modifiedColumns[':p' . $index++] = '`email`'; - } - if ($this->isColumnModified(CustomerPeer::PASSWORD)) { - $modifiedColumns[':p' . $index++] = '`password`'; - } - if ($this->isColumnModified(CustomerPeer::ALGO)) { - $modifiedColumns[':p' . $index++] = '`algo`'; - } - if ($this->isColumnModified(CustomerPeer::SALT)) { - $modifiedColumns[':p' . $index++] = '`salt`'; - } - if ($this->isColumnModified(CustomerPeer::RESELLER)) { - $modifiedColumns[':p' . $index++] = '`reseller`'; - } - if ($this->isColumnModified(CustomerPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`lang`'; - } - if ($this->isColumnModified(CustomerPeer::SPONSOR)) { - $modifiedColumns[':p' . $index++] = '`sponsor`'; - } - if ($this->isColumnModified(CustomerPeer::DISCOUNT)) { - $modifiedColumns[':p' . $index++] = '`discount`'; - } - if ($this->isColumnModified(CustomerPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `customer` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`ref`': - $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); - break; - case '`customer_title_id`': - $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); - break; - case '`company`': - $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); - break; - case '`firstname`': - $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); - break; - case '`lastname`': - $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); - break; - case '`address1`': - $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); - break; - case '`address2`': - $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); - break; - case '`address3`': - $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); - break; - case '`zipcode`': - $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); - break; - case '`city`': - $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); - break; - case '`country_id`': - $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); - break; - case '`phone`': - $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); - break; - case '`cellphone`': - $stmt->bindValue($identifier, $this->cellphone, PDO::PARAM_STR); - break; - case '`email`': - $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); - break; - case '`password`': - $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); - break; - case '`algo`': - $stmt->bindValue($identifier, $this->algo, PDO::PARAM_STR); - break; - case '`salt`': - $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); - break; - case '`reseller`': - $stmt->bindValue($identifier, $this->reseller, PDO::PARAM_INT); - break; - case '`lang`': - $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); - break; - case '`sponsor`': - $stmt->bindValue($identifier, $this->sponsor, PDO::PARAM_STR); - break; - case '`discount`': - $stmt->bindValue($identifier, $this->discount, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomerTitle !== null) { - if (!$this->aCustomerTitle->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures()); - } - } - - - if (($retval = CustomerPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getRef(); - break; - case 2: - return $this->getCustomerTitleId(); - break; - case 3: - return $this->getCompany(); - break; - case 4: - return $this->getFirstname(); - break; - case 5: - return $this->getLastname(); - break; - case 6: - return $this->getAddress1(); - break; - case 7: - return $this->getAddress2(); - break; - case 8: - return $this->getAddress3(); - break; - case 9: - return $this->getZipcode(); - break; - case 10: - return $this->getCity(); - break; - case 11: - return $this->getCountryId(); - break; - case 12: - return $this->getPhone(); - break; - case 13: - return $this->getCellphone(); - break; - case 14: - return $this->getEmail(); - break; - case 15: - return $this->getPassword(); - break; - case 16: - return $this->getAlgo(); - break; - case 17: - return $this->getSalt(); - break; - case 18: - return $this->getReseller(); - break; - case 19: - return $this->getLang(); - break; - case 20: - return $this->getSponsor(); - break; - case 21: - return $this->getDiscount(); - break; - case 22: - return $this->getCreatedAt(); - break; - case 23: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Customer'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Customer'][$this->getPrimaryKey()] = true; - $keys = CustomerPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getRef(), - $keys[2] => $this->getCustomerTitleId(), - $keys[3] => $this->getCompany(), - $keys[4] => $this->getFirstname(), - $keys[5] => $this->getLastname(), - $keys[6] => $this->getAddress1(), - $keys[7] => $this->getAddress2(), - $keys[8] => $this->getAddress3(), - $keys[9] => $this->getZipcode(), - $keys[10] => $this->getCity(), - $keys[11] => $this->getCountryId(), - $keys[12] => $this->getPhone(), - $keys[13] => $this->getCellphone(), - $keys[14] => $this->getEmail(), - $keys[15] => $this->getPassword(), - $keys[16] => $this->getAlgo(), - $keys[17] => $this->getSalt(), - $keys[18] => $this->getReseller(), - $keys[19] => $this->getLang(), - $keys[20] => $this->getSponsor(), - $keys[21] => $this->getDiscount(), - $keys[22] => $this->getCreatedAt(), - $keys[23] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCustomerTitle) { - $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collAddresss) { - $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collOrders) { - $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CustomerPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setRef($value); - break; - case 2: - $this->setCustomerTitleId($value); - break; - case 3: - $this->setCompany($value); - break; - case 4: - $this->setFirstname($value); - break; - case 5: - $this->setLastname($value); - break; - case 6: - $this->setAddress1($value); - break; - case 7: - $this->setAddress2($value); - break; - case 8: - $this->setAddress3($value); - break; - case 9: - $this->setZipcode($value); - break; - case 10: - $this->setCity($value); - break; - case 11: - $this->setCountryId($value); - break; - case 12: - $this->setPhone($value); - break; - case 13: - $this->setCellphone($value); - break; - case 14: - $this->setEmail($value); - break; - case 15: - $this->setPassword($value); - break; - case 16: - $this->setAlgo($value); - break; - case 17: - $this->setSalt($value); - break; - case 18: - $this->setReseller($value); - break; - case 19: - $this->setLang($value); - break; - case 20: - $this->setSponsor($value); - break; - case 21: - $this->setDiscount($value); - break; - case 22: - $this->setCreatedAt($value); - break; - case 23: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CustomerPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCustomerTitleId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCompany($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAddress1($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setAddress2($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setAddress3($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setZipcode($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setCity($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPhone($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCellphone($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setEmail($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setPassword($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setAlgo($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setSalt($arr[$keys[17]]); - if (array_key_exists($keys[18], $arr)) $this->setReseller($arr[$keys[18]]); - if (array_key_exists($keys[19], $arr)) $this->setLang($arr[$keys[19]]); - if (array_key_exists($keys[20], $arr)) $this->setSponsor($arr[$keys[20]]); - if (array_key_exists($keys[21], $arr)) $this->setDiscount($arr[$keys[21]]); - if (array_key_exists($keys[22], $arr)) $this->setCreatedAt($arr[$keys[22]]); - if (array_key_exists($keys[23], $arr)) $this->setUpdatedAt($arr[$keys[23]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - - if ($this->isColumnModified(CustomerPeer::ID)) $criteria->add(CustomerPeer::ID, $this->id); - if ($this->isColumnModified(CustomerPeer::REF)) $criteria->add(CustomerPeer::REF, $this->ref); - if ($this->isColumnModified(CustomerPeer::CUSTOMER_TITLE_ID)) $criteria->add(CustomerPeer::CUSTOMER_TITLE_ID, $this->customer_title_id); - if ($this->isColumnModified(CustomerPeer::COMPANY)) $criteria->add(CustomerPeer::COMPANY, $this->company); - if ($this->isColumnModified(CustomerPeer::FIRSTNAME)) $criteria->add(CustomerPeer::FIRSTNAME, $this->firstname); - if ($this->isColumnModified(CustomerPeer::LASTNAME)) $criteria->add(CustomerPeer::LASTNAME, $this->lastname); - if ($this->isColumnModified(CustomerPeer::ADDRESS1)) $criteria->add(CustomerPeer::ADDRESS1, $this->address1); - if ($this->isColumnModified(CustomerPeer::ADDRESS2)) $criteria->add(CustomerPeer::ADDRESS2, $this->address2); - if ($this->isColumnModified(CustomerPeer::ADDRESS3)) $criteria->add(CustomerPeer::ADDRESS3, $this->address3); - if ($this->isColumnModified(CustomerPeer::ZIPCODE)) $criteria->add(CustomerPeer::ZIPCODE, $this->zipcode); - if ($this->isColumnModified(CustomerPeer::CITY)) $criteria->add(CustomerPeer::CITY, $this->city); - if ($this->isColumnModified(CustomerPeer::COUNTRY_ID)) $criteria->add(CustomerPeer::COUNTRY_ID, $this->country_id); - if ($this->isColumnModified(CustomerPeer::PHONE)) $criteria->add(CustomerPeer::PHONE, $this->phone); - if ($this->isColumnModified(CustomerPeer::CELLPHONE)) $criteria->add(CustomerPeer::CELLPHONE, $this->cellphone); - if ($this->isColumnModified(CustomerPeer::EMAIL)) $criteria->add(CustomerPeer::EMAIL, $this->email); - if ($this->isColumnModified(CustomerPeer::PASSWORD)) $criteria->add(CustomerPeer::PASSWORD, $this->password); - if ($this->isColumnModified(CustomerPeer::ALGO)) $criteria->add(CustomerPeer::ALGO, $this->algo); - if ($this->isColumnModified(CustomerPeer::SALT)) $criteria->add(CustomerPeer::SALT, $this->salt); - if ($this->isColumnModified(CustomerPeer::RESELLER)) $criteria->add(CustomerPeer::RESELLER, $this->reseller); - if ($this->isColumnModified(CustomerPeer::LANG)) $criteria->add(CustomerPeer::LANG, $this->lang); - if ($this->isColumnModified(CustomerPeer::SPONSOR)) $criteria->add(CustomerPeer::SPONSOR, $this->sponsor); - if ($this->isColumnModified(CustomerPeer::DISCOUNT)) $criteria->add(CustomerPeer::DISCOUNT, $this->discount); - if ($this->isColumnModified(CustomerPeer::CREATED_AT)) $criteria->add(CustomerPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CustomerPeer::UPDATED_AT)) $criteria->add(CustomerPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - $criteria->add(CustomerPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Customer (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setRef($this->getRef()); - $copyObj->setCustomerTitleId($this->getCustomerTitleId()); - $copyObj->setCompany($this->getCompany()); - $copyObj->setFirstname($this->getFirstname()); - $copyObj->setLastname($this->getLastname()); - $copyObj->setAddress1($this->getAddress1()); - $copyObj->setAddress2($this->getAddress2()); - $copyObj->setAddress3($this->getAddress3()); - $copyObj->setZipcode($this->getZipcode()); - $copyObj->setCity($this->getCity()); - $copyObj->setCountryId($this->getCountryId()); - $copyObj->setPhone($this->getPhone()); - $copyObj->setCellphone($this->getCellphone()); - $copyObj->setEmail($this->getEmail()); - $copyObj->setPassword($this->getPassword()); - $copyObj->setAlgo($this->getAlgo()); - $copyObj->setSalt($this->getSalt()); - $copyObj->setReseller($this->getReseller()); - $copyObj->setLang($this->getLang()); - $copyObj->setSponsor($this->getSponsor()); - $copyObj->setDiscount($this->getDiscount()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAddresss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAddress($relObj->copy($deepCopy)); - } - } - - foreach ($this->getOrders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrder($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Customer Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CustomerPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CustomerPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a CustomerTitle object. - * - * @param CustomerTitle $v - * @return Customer The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomerTitle(CustomerTitle $v = null) - { - if ($v === null) { - $this->setCustomerTitleId(NULL); - } else { - $this->setCustomerTitleId($v->getId()); - } - - $this->aCustomerTitle = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CustomerTitle object, it will not be re-added. - if ($v !== null) { - $v->addCustomer($this); - } - - - return $this; - } - - - /** - * Get the associated CustomerTitle object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CustomerTitle The associated CustomerTitle object. - * @throws PropelException - */ - public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCustomerTitle === null && ($this->customer_title_id !== null) && $doQuery) { - $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->customer_title_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomerTitle->addCustomers($this); - */ - } - - return $this->aCustomerTitle; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Address' == $relationName) { - $this->initAddresss(); - } - if ('Order' == $relationName) { - $this->initOrders(); - } - } - - /** - * Clears out the collAddresss collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Customer The current object (for fluent API support) - * @see addAddresss() - */ - public function clearAddresss() - { - $this->collAddresss = null; // important to set this to null since that means it is uninitialized - $this->collAddresssPartial = null; - - return $this; - } - - /** - * reset is the collAddresss collection loaded partially - * - * @return void - */ - public function resetPartialAddresss($v = true) - { - $this->collAddresssPartial = $v; - } - - /** - * Initializes the collAddresss collection. - * - * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAddresss($overrideExisting = true) - { - if (null !== $this->collAddresss && !$overrideExisting) { - return; - } - $this->collAddresss = new PropelObjectCollection(); - $this->collAddresss->setModel('Address'); - } - - /** - * Gets an array of Address objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Customer is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Address[] List of Address objects - * @throws PropelException - */ - public function getAddresss($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { - // return empty collection - $this->initAddresss(); - } else { - $collAddresss = AddressQuery::create(null, $criteria) - ->filterByCustomer($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAddresssPartial && count($collAddresss)) { - $this->initAddresss(false); - - foreach($collAddresss as $obj) { - if (false == $this->collAddresss->contains($obj)) { - $this->collAddresss->append($obj); - } - } - - $this->collAddresssPartial = true; - } - - $collAddresss->getInternalIterator()->rewind(); - return $collAddresss; - } - - if($partial && $this->collAddresss) { - foreach($this->collAddresss as $obj) { - if($obj->isNew()) { - $collAddresss[] = $obj; - } - } - } - - $this->collAddresss = $collAddresss; - $this->collAddresssPartial = false; - } - } - - return $this->collAddresss; - } - - /** - * Sets a collection of Address objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $addresss A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Customer The current object (for fluent API support) - */ - public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) - { - $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); - - $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); - - foreach ($addresssToDelete as $addressRemoved) { - $addressRemoved->setCustomer(null); - } - - $this->collAddresss = null; - foreach ($addresss as $address) { - $this->addAddress($address); - } - - $this->collAddresss = $addresss; - $this->collAddresssPartial = false; - - return $this; - } - - /** - * Returns the number of related Address objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Address objects. - * @throws PropelException - */ - public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAddresss()); - } - $query = AddressQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomer($this) - ->count($con); - } - - return count($this->collAddresss); - } - - /** - * Method called to associate a Address object to this object - * through the Address foreign key attribute. - * - * @param Address $l Address - * @return Customer The current object (for fluent API support) - */ - public function addAddress(Address $l) - { - if ($this->collAddresss === null) { - $this->initAddresss(); - $this->collAddresssPartial = true; - } - if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAddress($l); - } - - return $this; - } - - /** - * @param Address $address The address object to add. - */ - protected function doAddAddress($address) - { - $this->collAddresss[]= $address; - $address->setCustomer($this); - } - - /** - * @param Address $address The address object to remove. - * @return Customer The current object (for fluent API support) - */ - public function removeAddress($address) - { - if ($this->getAddresss()->contains($address)) { - $this->collAddresss->remove($this->collAddresss->search($address)); - if (null === $this->addresssScheduledForDeletion) { - $this->addresssScheduledForDeletion = clone $this->collAddresss; - $this->addresssScheduledForDeletion->clear(); - } - $this->addresssScheduledForDeletion[]= clone $address; - $address->setCustomer(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Customer is new, it will return - * an empty collection; or if this Customer has previously - * been saved, it will retrieve related Addresss from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Customer. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Address[] List of Address objects - */ - public function getAddresssJoinCustomerTitle($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AddressQuery::create(null, $criteria); - $query->joinWith('CustomerTitle', $join_behavior); - - return $this->getAddresss($query, $con); - } - - /** - * Clears out the collOrders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Customer The current object (for fluent API support) - * @see addOrders() - */ - public function clearOrders() - { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; - } - - /** - * reset is the collOrders collection loaded partially - * - * @return void - */ - public function resetPartialOrders($v = true) - { - $this->collOrdersPartial = $v; - } - - /** - * Initializes the collOrders collection. - * - * By default this just sets the collOrders collection to an empty array (like clearcollOrders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrders($overrideExisting = true) - { - if (null !== $this->collOrders && !$overrideExisting) { - return; - } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); - } - - /** - * Gets an array of Order objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Customer is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Order[] List of Order objects - * @throws PropelException - */ - public function getOrders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - // return empty collection - $this->initOrders(); - } else { - $collOrders = OrderQuery::create(null, $criteria) - ->filterByCustomer($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); - - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); - } - } - - $this->collOrdersPartial = true; - } - - $collOrders->getInternalIterator()->rewind(); - return $collOrders; - } - - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { - $collOrders[] = $obj; - } - } - } - - $this->collOrders = $collOrders; - $this->collOrdersPartial = false; - } - } - - return $this->collOrders; - } - - /** - * Sets a collection of Order objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $orders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Customer The current object (for fluent API support) - */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) - { - $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); - - foreach ($ordersToDelete as $orderRemoved) { - $orderRemoved->setCustomer(null); - } - - $this->collOrders = null; - foreach ($orders as $order) { - $this->addOrder($order); - } - - $this->collOrders = $orders; - $this->collOrdersPartial = false; - - return $this; - } - - /** - * Returns the number of related Order objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Order objects. - * @throws PropelException - */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomer($this) - ->count($con); - } - - return count($this->collOrders); - } - - /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. - * - * @param Order $l Order - * @return Customer The current object (for fluent API support) - */ - public function addOrder(Order $l) - { - if ($this->collOrders === null) { - $this->initOrders(); - $this->collOrdersPartial = true; - } - if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrder($l); - } - - return $this; - } - - /** - * @param Order $order The order object to add. - */ - protected function doAddOrder($order) - { - $this->collOrders[]= $order; - $order->setCustomer($this); - } - - /** - * @param Order $order The order object to remove. - * @return Customer The current object (for fluent API support) - */ - public function removeOrder($order) - { - if ($this->getOrders()->contains($order)) { - $this->collOrders->remove($this->collOrders->search($order)); - if (null === $this->ordersScheduledForDeletion) { - $this->ordersScheduledForDeletion = clone $this->collOrders; - $this->ordersScheduledForDeletion->clear(); - } - $this->ordersScheduledForDeletion[]= clone $order; - $order->setCustomer(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Customer is new, it will return - * an empty collection; or if this Customer has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Customer. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Customer is new, it will return - * an empty collection; or if this Customer has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Customer. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Customer is new, it will return - * an empty collection; or if this Customer has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Customer. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Customer is new, it will return - * an empty collection; or if this Customer has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Customer. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); - - return $this->getOrders($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->ref = null; - $this->customer_title_id = null; - $this->company = null; - $this->firstname = null; - $this->lastname = null; - $this->address1 = null; - $this->address2 = null; - $this->address3 = null; - $this->zipcode = null; - $this->city = null; - $this->country_id = null; - $this->phone = null; - $this->cellphone = null; - $this->email = null; - $this->password = null; - $this->algo = null; - $this->salt = null; - $this->reseller = null; - $this->lang = null; - $this->sponsor = null; - $this->discount = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAddresss) { - foreach ($this->collAddresss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collOrders) { - foreach ($this->collOrders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aCustomerTitle instanceof Persistent) { - $this->aCustomerTitle->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collAddresss instanceof PropelCollection) { - $this->collAddresss->clearIterator(); - } - $this->collAddresss = null; - if ($this->collOrders instanceof PropelCollection) { - $this->collOrders->clearIterator(); - } - $this->collOrders = null; - $this->aCustomerTitle = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CustomerPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Customer The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CustomerPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCustomerPeer.php b/core/lib/Thelia/Model/om/BaseCustomerPeer.php deleted file mode 100755 index 6b30317fe..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerPeer.php +++ /dev/null @@ -1,1132 +0,0 @@ - array ('Id', 'Ref', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'CountryId', 'Phone', 'Cellphone', 'Email', 'Password', 'Algo', 'Salt', 'Reseller', 'Lang', 'Sponsor', 'Discount', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'countryId', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CustomerPeer::ID, CustomerPeer::REF, CustomerPeer::CUSTOMER_TITLE_ID, CustomerPeer::COMPANY, CustomerPeer::FIRSTNAME, CustomerPeer::LASTNAME, CustomerPeer::ADDRESS1, CustomerPeer::ADDRESS2, CustomerPeer::ADDRESS3, CustomerPeer::ZIPCODE, CustomerPeer::CITY, CustomerPeer::COUNTRY_ID, CustomerPeer::PHONE, CustomerPeer::CELLPHONE, CustomerPeer::EMAIL, CustomerPeer::PASSWORD, CustomerPeer::ALGO, CustomerPeer::SALT, CustomerPeer::RESELLER, CustomerPeer::LANG, CustomerPeer::SPONSOR, CustomerPeer::DISCOUNT, CustomerPeer::CREATED_AT, CustomerPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'COUNTRY_ID', 'PHONE', 'CELLPHONE', 'EMAIL', 'PASSWORD', 'ALGO', 'SALT', 'RESELLER', 'LANG', 'SPONSOR', 'DISCOUNT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'country_id', 'phone', 'cellphone', 'email', 'password', 'algo', 'salt', 'reseller', 'lang', 'sponsor', 'discount', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CustomerPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerTitleId' => 2, 'Company' => 3, 'Firstname' => 4, 'Lastname' => 5, 'Address1' => 6, 'Address2' => 7, 'Address3' => 8, 'Zipcode' => 9, 'City' => 10, 'CountryId' => 11, 'Phone' => 12, 'Cellphone' => 13, 'Email' => 14, 'Password' => 15, 'Algo' => 16, 'Salt' => 17, 'Reseller' => 18, 'Lang' => 19, 'Sponsor' => 20, 'Discount' => 21, 'CreatedAt' => 22, 'UpdatedAt' => 23, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerTitleId' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'countryId' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'createdAt' => 22, 'updatedAt' => 23, ), - BasePeer::TYPE_COLNAME => array (CustomerPeer::ID => 0, CustomerPeer::REF => 1, CustomerPeer::CUSTOMER_TITLE_ID => 2, CustomerPeer::COMPANY => 3, CustomerPeer::FIRSTNAME => 4, CustomerPeer::LASTNAME => 5, CustomerPeer::ADDRESS1 => 6, CustomerPeer::ADDRESS2 => 7, CustomerPeer::ADDRESS3 => 8, CustomerPeer::ZIPCODE => 9, CustomerPeer::CITY => 10, CustomerPeer::COUNTRY_ID => 11, CustomerPeer::PHONE => 12, CustomerPeer::CELLPHONE => 13, CustomerPeer::EMAIL => 14, CustomerPeer::PASSWORD => 15, CustomerPeer::ALGO => 16, CustomerPeer::SALT => 17, CustomerPeer::RESELLER => 18, CustomerPeer::LANG => 19, CustomerPeer::SPONSOR => 20, CustomerPeer::DISCOUNT => 21, CustomerPeer::CREATED_AT => 22, CustomerPeer::UPDATED_AT => 23, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_TITLE_ID' => 2, 'COMPANY' => 3, 'FIRSTNAME' => 4, 'LASTNAME' => 5, 'ADDRESS1' => 6, 'ADDRESS2' => 7, 'ADDRESS3' => 8, 'ZIPCODE' => 9, 'CITY' => 10, 'COUNTRY_ID' => 11, 'PHONE' => 12, 'CELLPHONE' => 13, 'EMAIL' => 14, 'PASSWORD' => 15, 'ALGO' => 16, 'SALT' => 17, 'RESELLER' => 18, 'LANG' => 19, 'SPONSOR' => 20, 'DISCOUNT' => 21, 'CREATED_AT' => 22, 'UPDATED_AT' => 23, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_title_id' => 2, 'company' => 3, 'firstname' => 4, 'lastname' => 5, 'address1' => 6, 'address2' => 7, 'address3' => 8, 'zipcode' => 9, 'city' => 10, 'country_id' => 11, 'phone' => 12, 'cellphone' => 13, 'email' => 14, 'password' => 15, 'algo' => 16, 'salt' => 17, 'reseller' => 18, 'lang' => 19, 'sponsor' => 20, 'discount' => 21, 'created_at' => 22, 'updated_at' => 23, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CustomerPeer::getFieldNames($toType); - $key = isset(CustomerPeer::$fieldKeys[$fromType][$name]) ? CustomerPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CustomerPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CustomerPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CustomerPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CustomerPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CustomerPeer::ID); - $criteria->addSelectColumn(CustomerPeer::REF); - $criteria->addSelectColumn(CustomerPeer::CUSTOMER_TITLE_ID); - $criteria->addSelectColumn(CustomerPeer::COMPANY); - $criteria->addSelectColumn(CustomerPeer::FIRSTNAME); - $criteria->addSelectColumn(CustomerPeer::LASTNAME); - $criteria->addSelectColumn(CustomerPeer::ADDRESS1); - $criteria->addSelectColumn(CustomerPeer::ADDRESS2); - $criteria->addSelectColumn(CustomerPeer::ADDRESS3); - $criteria->addSelectColumn(CustomerPeer::ZIPCODE); - $criteria->addSelectColumn(CustomerPeer::CITY); - $criteria->addSelectColumn(CustomerPeer::COUNTRY_ID); - $criteria->addSelectColumn(CustomerPeer::PHONE); - $criteria->addSelectColumn(CustomerPeer::CELLPHONE); - $criteria->addSelectColumn(CustomerPeer::EMAIL); - $criteria->addSelectColumn(CustomerPeer::PASSWORD); - $criteria->addSelectColumn(CustomerPeer::ALGO); - $criteria->addSelectColumn(CustomerPeer::SALT); - $criteria->addSelectColumn(CustomerPeer::RESELLER); - $criteria->addSelectColumn(CustomerPeer::LANG); - $criteria->addSelectColumn(CustomerPeer::SPONSOR); - $criteria->addSelectColumn(CustomerPeer::DISCOUNT); - $criteria->addSelectColumn(CustomerPeer::CREATED_AT); - $criteria->addSelectColumn(CustomerPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.ref'); - $criteria->addSelectColumn($alias . '.customer_title_id'); - $criteria->addSelectColumn($alias . '.company'); - $criteria->addSelectColumn($alias . '.firstname'); - $criteria->addSelectColumn($alias . '.lastname'); - $criteria->addSelectColumn($alias . '.address1'); - $criteria->addSelectColumn($alias . '.address2'); - $criteria->addSelectColumn($alias . '.address3'); - $criteria->addSelectColumn($alias . '.zipcode'); - $criteria->addSelectColumn($alias . '.city'); - $criteria->addSelectColumn($alias . '.country_id'); - $criteria->addSelectColumn($alias . '.phone'); - $criteria->addSelectColumn($alias . '.cellphone'); - $criteria->addSelectColumn($alias . '.email'); - $criteria->addSelectColumn($alias . '.password'); - $criteria->addSelectColumn($alias . '.algo'); - $criteria->addSelectColumn($alias . '.salt'); - $criteria->addSelectColumn($alias . '.reseller'); - $criteria->addSelectColumn($alias . '.lang'); - $criteria->addSelectColumn($alias . '.sponsor'); - $criteria->addSelectColumn($alias . '.discount'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CustomerPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Customer - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CustomerPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CustomerPeer::populateObjects(CustomerPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CustomerPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Customer $obj A Customer object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CustomerPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Customer object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Customer) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Customer object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CustomerPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Customer Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CustomerPeer::$instances[$key])) { - return CustomerPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CustomerPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CustomerPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to customer - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AddressPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AddressPeer::clearInstancePool(); - // Invalidate objects in OrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CustomerPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CustomerPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CustomerPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Customer object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CustomerPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CustomerPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CustomerPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CustomerPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related CustomerTitle table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Customer objects pre-filled with their CustomerTitle objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Customer objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - } - - CustomerPeer::addSelectColumns($criteria); - $startcol = CustomerPeer::NUM_HYDRATE_COLUMNS; - CustomerTitlePeer::addSelectColumns($criteria); - - $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CustomerPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CustomerPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Customer) to $obj2 (CustomerTitle) - $obj2->addCustomer($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CustomerPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Customer objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Customer objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - } - - CustomerPeer::addSelectColumns($criteria); - $startcol2 = CustomerPeer::NUM_HYDRATE_COLUMNS; - - CustomerTitlePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CustomerPeer::CUSTOMER_TITLE_ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CustomerPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CustomerPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CustomerPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CustomerPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CustomerTitle rows - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Customer) to the collection in $obj2 (CustomerTitle) - $obj2->addCustomer($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME)->getTable(CustomerPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCustomerPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCustomerPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CustomerTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CustomerPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Customer or Criteria object. - * - * @param mixed $values Criteria or Customer object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Customer object - } - - if ($criteria->containsKey(CustomerPeer::ID) && $criteria->keyContainsValue(CustomerPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Customer or Criteria object. - * - * @param mixed $values Criteria or Customer object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CustomerPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CustomerPeer::ID); - $value = $criteria->remove(CustomerPeer::ID); - if ($value) { - $selectCriteria->add(CustomerPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CustomerPeer::TABLE_NAME); - } - - } else { // $values is Customer object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the customer table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CustomerPeer::TABLE_NAME, $con, CustomerPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CustomerPeer::clearInstancePool(); - CustomerPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Customer or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Customer object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CustomerPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Customer) { // it's a model object - // invalidate the cache for this single object - CustomerPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - $criteria->add(CustomerPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CustomerPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CustomerPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CustomerPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Customer object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Customer $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CustomerPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CustomerPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CustomerPeer::DATABASE_NAME, CustomerPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Customer - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CustomerPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - $criteria->add(CustomerPeer::ID, $pk); - - $v = CustomerPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Customer[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CustomerPeer::DATABASE_NAME); - $criteria->add(CustomerPeer::ID, $pks, Criteria::IN); - $objs = CustomerPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCustomerPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCustomerPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCustomerQuery.php b/core/lib/Thelia/Model/om/BaseCustomerQuery.php deleted file mode 100755 index 7f839c024..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerQuery.php +++ /dev/null @@ -1,1432 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Customer|Customer[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CustomerPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CustomerPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Customer A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Customer A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `ref`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `country_id`, `phone`, `cellphone`, `email`, `password`, `algo`, `salt`, `reseller`, `lang`, `sponsor`, `discount`, `created_at`, `updated_at` FROM `customer` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Customer(); - $obj->hydrate($row); - CustomerPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Customer|Customer[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Customer[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CustomerPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CustomerPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CustomerPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CustomerPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the ref column - * - * Example usage: - * - * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue' - * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%' - * - * - * @param string $ref The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByRef($ref = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($ref)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $ref)) { - $ref = str_replace('*', '%', $ref); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::REF, $ref, $comparison); - } - - /** - * Filter the query on the customer_title_id column - * - * Example usage: - * - * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 - * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 - * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 - * - * - * @see filterByCustomerTitle() - * - * @param mixed $customerTitleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCustomerTitleId($customerTitleId = null, $comparison = null) - { - if (is_array($customerTitleId)) { - $useMinMax = false; - if (isset($customerTitleId['min'])) { - $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerTitleId['max'])) { - $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); - } - - /** - * Filter the query on the company column - * - * Example usage: - * - * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue' - * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%' - * - * - * @param string $company The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCompany($company = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($company)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $company)) { - $company = str_replace('*', '%', $company); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::COMPANY, $company, $comparison); - } - - /** - * Filter the query on the firstname column - * - * Example usage: - * - * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue' - * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%' - * - * - * @param string $firstname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByFirstname($firstname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($firstname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $firstname)) { - $firstname = str_replace('*', '%', $firstname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::FIRSTNAME, $firstname, $comparison); - } - - /** - * Filter the query on the lastname column - * - * Example usage: - * - * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue' - * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%' - * - * - * @param string $lastname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByLastname($lastname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lastname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lastname)) { - $lastname = str_replace('*', '%', $lastname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::LASTNAME, $lastname, $comparison); - } - - /** - * Filter the query on the address1 column - * - * Example usage: - * - * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue' - * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%' - * - * - * @param string $address1 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByAddress1($address1 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address1)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address1)) { - $address1 = str_replace('*', '%', $address1); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::ADDRESS1, $address1, $comparison); - } - - /** - * Filter the query on the address2 column - * - * Example usage: - * - * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue' - * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%' - * - * - * @param string $address2 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByAddress2($address2 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address2)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address2)) { - $address2 = str_replace('*', '%', $address2); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::ADDRESS2, $address2, $comparison); - } - - /** - * Filter the query on the address3 column - * - * Example usage: - * - * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue' - * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%' - * - * - * @param string $address3 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByAddress3($address3 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address3)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address3)) { - $address3 = str_replace('*', '%', $address3); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::ADDRESS3, $address3, $comparison); - } - - /** - * Filter the query on the zipcode column - * - * Example usage: - * - * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue' - * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%' - * - * - * @param string $zipcode The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByZipcode($zipcode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($zipcode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $zipcode)) { - $zipcode = str_replace('*', '%', $zipcode); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::ZIPCODE, $zipcode, $comparison); - } - - /** - * Filter the query on the city column - * - * Example usage: - * - * $query->filterByCity('fooValue'); // WHERE city = 'fooValue' - * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%' - * - * - * @param string $city The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCity($city = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($city)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $city)) { - $city = str_replace('*', '%', $city); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::CITY, $city, $comparison); - } - - /** - * Filter the query on the country_id column - * - * Example usage: - * - * $query->filterByCountryId(1234); // WHERE country_id = 1234 - * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 - * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 - * - * - * @param mixed $countryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCountryId($countryId = null, $comparison = null) - { - if (is_array($countryId)) { - $useMinMax = false; - if (isset($countryId['min'])) { - $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($countryId['max'])) { - $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId, $comparison); - } - - /** - * Filter the query on the phone column - * - * Example usage: - * - * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue' - * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%' - * - * - * @param string $phone The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByPhone($phone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($phone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $phone)) { - $phone = str_replace('*', '%', $phone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::PHONE, $phone, $comparison); - } - - /** - * Filter the query on the cellphone column - * - * Example usage: - * - * $query->filterByCellphone('fooValue'); // WHERE cellphone = 'fooValue' - * $query->filterByCellphone('%fooValue%'); // WHERE cellphone LIKE '%fooValue%' - * - * - * @param string $cellphone The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCellphone($cellphone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($cellphone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $cellphone)) { - $cellphone = str_replace('*', '%', $cellphone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::CELLPHONE, $cellphone, $comparison); - } - - /** - * Filter the query on the email column - * - * Example usage: - * - * $query->filterByEmail('fooValue'); // WHERE email = 'fooValue' - * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%' - * - * - * @param string $email The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByEmail($email = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($email)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $email)) { - $email = str_replace('*', '%', $email); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::EMAIL, $email, $comparison); - } - - /** - * Filter the query on the password column - * - * Example usage: - * - * $query->filterByPassword('fooValue'); // WHERE password = 'fooValue' - * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%' - * - * - * @param string $password The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByPassword($password = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($password)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $password)) { - $password = str_replace('*', '%', $password); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::PASSWORD, $password, $comparison); - } - - /** - * Filter the query on the algo column - * - * Example usage: - * - * $query->filterByAlgo('fooValue'); // WHERE algo = 'fooValue' - * $query->filterByAlgo('%fooValue%'); // WHERE algo LIKE '%fooValue%' - * - * - * @param string $algo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByAlgo($algo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($algo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $algo)) { - $algo = str_replace('*', '%', $algo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::ALGO, $algo, $comparison); - } - - /** - * Filter the query on the salt column - * - * Example usage: - * - * $query->filterBySalt('fooValue'); // WHERE salt = 'fooValue' - * $query->filterBySalt('%fooValue%'); // WHERE salt LIKE '%fooValue%' - * - * - * @param string $salt The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterBySalt($salt = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($salt)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $salt)) { - $salt = str_replace('*', '%', $salt); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::SALT, $salt, $comparison); - } - - /** - * Filter the query on the reseller column - * - * Example usage: - * - * $query->filterByReseller(1234); // WHERE reseller = 1234 - * $query->filterByReseller(array(12, 34)); // WHERE reseller IN (12, 34) - * $query->filterByReseller(array('min' => 12)); // WHERE reseller >= 12 - * $query->filterByReseller(array('max' => 12)); // WHERE reseller <= 12 - * - * - * @param mixed $reseller The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByReseller($reseller = null, $comparison = null) - { - if (is_array($reseller)) { - $useMinMax = false; - if (isset($reseller['min'])) { - $this->addUsingAlias(CustomerPeer::RESELLER, $reseller['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($reseller['max'])) { - $this->addUsingAlias(CustomerPeer::RESELLER, $reseller['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::RESELLER, $reseller, $comparison); - } - - /** - * Filter the query on the lang column - * - * Example usage: - * - * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue' - * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%' - * - * - * @param string $lang The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByLang($lang = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lang)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lang)) { - $lang = str_replace('*', '%', $lang); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::LANG, $lang, $comparison); - } - - /** - * Filter the query on the sponsor column - * - * Example usage: - * - * $query->filterBySponsor('fooValue'); // WHERE sponsor = 'fooValue' - * $query->filterBySponsor('%fooValue%'); // WHERE sponsor LIKE '%fooValue%' - * - * - * @param string $sponsor The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterBySponsor($sponsor = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($sponsor)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $sponsor)) { - $sponsor = str_replace('*', '%', $sponsor); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerPeer::SPONSOR, $sponsor, $comparison); - } - - /** - * Filter the query on the discount column - * - * Example usage: - * - * $query->filterByDiscount(1234); // WHERE discount = 1234 - * $query->filterByDiscount(array(12, 34)); // WHERE discount IN (12, 34) - * $query->filterByDiscount(array('min' => 12)); // WHERE discount >= 12 - * $query->filterByDiscount(array('max' => 12)); // WHERE discount <= 12 - * - * - * @param mixed $discount The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByDiscount($discount = null, $comparison = null) - { - if (is_array($discount)) { - $useMinMax = false; - if (isset($discount['min'])) { - $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($discount['max'])) { - $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::DISCOUNT, $discount, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related CustomerTitle object - * - * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomerTitle($customerTitle, $comparison = null) - { - if ($customerTitle instanceof CustomerTitle) { - return $this - ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CustomerPeer::CUSTOMER_TITLE_ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CustomerTitle relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerQuery The current query, for fluid interface - */ - public function joinCustomerTitle($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CustomerTitle'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CustomerTitle'); - } - - return $this; - } - - /** - * Use the CustomerTitle relation CustomerTitle object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query - */ - public function useCustomerTitleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCustomerTitle($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); - } - - /** - * Filter the query by a related Address object - * - * @param Address|PropelObjectCollection $address the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAddress($address, $comparison = null) - { - if ($address instanceof Address) { - return $this - ->addUsingAlias(CustomerPeer::ID, $address->getCustomerId(), $comparison); - } elseif ($address instanceof PropelObjectCollection) { - return $this - ->useAddressQuery() - ->filterByPrimaryKeys($address->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Address relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerQuery The current query, for fluid interface - */ - public function joinAddress($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Address'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Address'); - } - - return $this; - } - - /** - * Use the Address relation Address object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query - */ - public function useAddressQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAddress($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery'); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(CustomerPeer::ID, $order->getCustomerId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - return $this - ->useOrderQuery() - ->filterByPrimaryKeys($order->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Exclude object from result - * - * @param Customer $customer Object to remove from the list of results - * - * @return CustomerQuery The current query, for fluid interface - */ - public function prune($customer = null) - { - if ($customer) { - $this->addUsingAlias(CustomerPeer::ID, $customer->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CustomerQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CustomerPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CustomerQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CustomerPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CustomerQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CustomerPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CustomerQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CustomerPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CustomerQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CustomerPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CustomerQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CustomerPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitle.php b/core/lib/Thelia/Model/om/BaseCustomerTitle.php deleted file mode 100755 index 3d1967579..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitle.php +++ /dev/null @@ -1,2180 +0,0 @@ -by_default = 0; - } - - /** - * Initializes internal state of BaseCustomerTitle object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [by_default] column value. - * - * @return int - */ - public function getByDefault() - { - return $this->by_default; - } - - /** - * Get the [position] column value. - * - * @return string - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CustomerTitle The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CustomerTitlePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [by_default] column. - * - * @param int $v new value - * @return CustomerTitle The current object (for fluent API support) - */ - public function setByDefault($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = CustomerTitlePeer::BY_DEFAULT; - } - - - return $this; - } // setByDefault() - - /** - * Set the value of [position] column. - * - * @param string $v new value - * @return CustomerTitle The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = CustomerTitlePeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CustomerTitle The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = CustomerTitlePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return CustomerTitle The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = CustomerTitlePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->by_default !== 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->by_default = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->position = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = CustomerTitlePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CustomerTitle object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = CustomerTitlePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collCustomers = null; - - $this->collAddresss = null; - - $this->collCustomerTitleI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CustomerTitleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - CustomerTitlePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->customersScheduledForDeletion !== null) { - if (!$this->customersScheduledForDeletion->isEmpty()) { - foreach ($this->customersScheduledForDeletion as $customer) { - // need to save related object because we set the relation to null - $customer->save($con); - } - $this->customersScheduledForDeletion = null; - } - } - - if ($this->collCustomers !== null) { - foreach ($this->collCustomers as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->addresssScheduledForDeletion !== null) { - if (!$this->addresssScheduledForDeletion->isEmpty()) { - foreach ($this->addresssScheduledForDeletion as $address) { - // need to save related object because we set the relation to null - $address->save($con); - } - $this->addresssScheduledForDeletion = null; - } - } - - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->customerTitleI18nsScheduledForDeletion !== null) { - if (!$this->customerTitleI18nsScheduledForDeletion->isEmpty()) { - CustomerTitleI18nQuery::create() - ->filterByPrimaryKeys($this->customerTitleI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->customerTitleI18nsScheduledForDeletion = null; - } - } - - if ($this->collCustomerTitleI18ns !== null) { - foreach ($this->collCustomerTitleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = CustomerTitlePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . CustomerTitlePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CustomerTitlePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; - } - if ($this->isColumnModified(CustomerTitlePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `customer_title` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`by_default`': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = CustomerTitlePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collCustomers !== null) { - foreach ($this->collCustomers as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAddresss !== null) { - foreach ($this->collAddresss as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCustomerTitleI18ns !== null) { - foreach ($this->collCustomerTitleI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getByDefault(); - break; - case 2: - return $this->getPosition(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CustomerTitle'][$this->getPrimaryKey()] = true; - $keys = CustomerTitlePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getByDefault(), - $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collCustomers) { - $result['Customers'] = $this->collCustomers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAddresss) { - $result['Addresss'] = $this->collAddresss->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collCustomerTitleI18ns) { - $result['CustomerTitleI18ns'] = $this->collCustomerTitleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CustomerTitlePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setByDefault($value); - break; - case 2: - $this->setPosition($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = CustomerTitlePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setByDefault($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - - if ($this->isColumnModified(CustomerTitlePeer::ID)) $criteria->add(CustomerTitlePeer::ID, $this->id); - if ($this->isColumnModified(CustomerTitlePeer::BY_DEFAULT)) $criteria->add(CustomerTitlePeer::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(CustomerTitlePeer::POSITION)) $criteria->add(CustomerTitlePeer::POSITION, $this->position); - if ($this->isColumnModified(CustomerTitlePeer::CREATED_AT)) $criteria->add(CustomerTitlePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(CustomerTitlePeer::UPDATED_AT)) $criteria->add(CustomerTitlePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - $criteria->add(CustomerTitlePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of CustomerTitle (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setByDefault($this->getByDefault()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getCustomers() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCustomer($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAddresss() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAddress($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCustomerTitleI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCustomerTitleI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return CustomerTitle Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return CustomerTitlePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CustomerTitlePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Customer' == $relationName) { - $this->initCustomers(); - } - if ('Address' == $relationName) { - $this->initAddresss(); - } - if ('CustomerTitleI18n' == $relationName) { - $this->initCustomerTitleI18ns(); - } - } - - /** - * Clears out the collCustomers collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return CustomerTitle The current object (for fluent API support) - * @see addCustomers() - */ - public function clearCustomers() - { - $this->collCustomers = null; // important to set this to null since that means it is uninitialized - $this->collCustomersPartial = null; - - return $this; - } - - /** - * reset is the collCustomers collection loaded partially - * - * @return void - */ - public function resetPartialCustomers($v = true) - { - $this->collCustomersPartial = $v; - } - - /** - * Initializes the collCustomers collection. - * - * By default this just sets the collCustomers collection to an empty array (like clearcollCustomers()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCustomers($overrideExisting = true) - { - if (null !== $this->collCustomers && !$overrideExisting) { - return; - } - $this->collCustomers = new PropelObjectCollection(); - $this->collCustomers->setModel('Customer'); - } - - /** - * Gets an array of Customer objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this CustomerTitle is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Customer[] List of Customer objects - * @throws PropelException - */ - public function getCustomers($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - if (null === $this->collCustomers || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomers) { - // return empty collection - $this->initCustomers(); - } else { - $collCustomers = CustomerQuery::create(null, $criteria) - ->filterByCustomerTitle($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCustomersPartial && count($collCustomers)) { - $this->initCustomers(false); - - foreach($collCustomers as $obj) { - if (false == $this->collCustomers->contains($obj)) { - $this->collCustomers->append($obj); - } - } - - $this->collCustomersPartial = true; - } - - $collCustomers->getInternalIterator()->rewind(); - return $collCustomers; - } - - if($partial && $this->collCustomers) { - foreach($this->collCustomers as $obj) { - if($obj->isNew()) { - $collCustomers[] = $obj; - } - } - } - - $this->collCustomers = $collCustomers; - $this->collCustomersPartial = false; - } - } - - return $this->collCustomers; - } - - /** - * Sets a collection of Customer objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $customers A Propel collection. - * @param PropelPDO $con Optional connection object - * @return CustomerTitle The current object (for fluent API support) - */ - public function setCustomers(PropelCollection $customers, PropelPDO $con = null) - { - $customersToDelete = $this->getCustomers(new Criteria(), $con)->diff($customers); - - $this->customersScheduledForDeletion = unserialize(serialize($customersToDelete)); - - foreach ($customersToDelete as $customerRemoved) { - $customerRemoved->setCustomerTitle(null); - } - - $this->collCustomers = null; - foreach ($customers as $customer) { - $this->addCustomer($customer); - } - - $this->collCustomers = $customers; - $this->collCustomersPartial = false; - - return $this; - } - - /** - * Returns the number of related Customer objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Customer objects. - * @throws PropelException - */ - public function countCustomers(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCustomersPartial && !$this->isNew(); - if (null === $this->collCustomers || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomers) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCustomers()); - } - $query = CustomerQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); - } - - return count($this->collCustomers); - } - - /** - * Method called to associate a Customer object to this object - * through the Customer foreign key attribute. - * - * @param Customer $l Customer - * @return CustomerTitle The current object (for fluent API support) - */ - public function addCustomer(Customer $l) - { - if ($this->collCustomers === null) { - $this->initCustomers(); - $this->collCustomersPartial = true; - } - if (!in_array($l, $this->collCustomers->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCustomer($l); - } - - return $this; - } - - /** - * @param Customer $customer The customer object to add. - */ - protected function doAddCustomer($customer) - { - $this->collCustomers[]= $customer; - $customer->setCustomerTitle($this); - } - - /** - * @param Customer $customer The customer object to remove. - * @return CustomerTitle The current object (for fluent API support) - */ - public function removeCustomer($customer) - { - if ($this->getCustomers()->contains($customer)) { - $this->collCustomers->remove($this->collCustomers->search($customer)); - if (null === $this->customersScheduledForDeletion) { - $this->customersScheduledForDeletion = clone $this->collCustomers; - $this->customersScheduledForDeletion->clear(); - } - $this->customersScheduledForDeletion[]= $customer; - $customer->setCustomerTitle(null); - } - - return $this; - } - - /** - * Clears out the collAddresss collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return CustomerTitle The current object (for fluent API support) - * @see addAddresss() - */ - public function clearAddresss() - { - $this->collAddresss = null; // important to set this to null since that means it is uninitialized - $this->collAddresssPartial = null; - - return $this; - } - - /** - * reset is the collAddresss collection loaded partially - * - * @return void - */ - public function resetPartialAddresss($v = true) - { - $this->collAddresssPartial = $v; - } - - /** - * Initializes the collAddresss collection. - * - * By default this just sets the collAddresss collection to an empty array (like clearcollAddresss()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAddresss($overrideExisting = true) - { - if (null !== $this->collAddresss && !$overrideExisting) { - return; - } - $this->collAddresss = new PropelObjectCollection(); - $this->collAddresss->setModel('Address'); - } - - /** - * Gets an array of Address objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this CustomerTitle is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Address[] List of Address objects - * @throws PropelException - */ - public function getAddresss($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { - // return empty collection - $this->initAddresss(); - } else { - $collAddresss = AddressQuery::create(null, $criteria) - ->filterByCustomerTitle($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAddresssPartial && count($collAddresss)) { - $this->initAddresss(false); - - foreach($collAddresss as $obj) { - if (false == $this->collAddresss->contains($obj)) { - $this->collAddresss->append($obj); - } - } - - $this->collAddresssPartial = true; - } - - $collAddresss->getInternalIterator()->rewind(); - return $collAddresss; - } - - if($partial && $this->collAddresss) { - foreach($this->collAddresss as $obj) { - if($obj->isNew()) { - $collAddresss[] = $obj; - } - } - } - - $this->collAddresss = $collAddresss; - $this->collAddresssPartial = false; - } - } - - return $this->collAddresss; - } - - /** - * Sets a collection of Address objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $addresss A Propel collection. - * @param PropelPDO $con Optional connection object - * @return CustomerTitle The current object (for fluent API support) - */ - public function setAddresss(PropelCollection $addresss, PropelPDO $con = null) - { - $addresssToDelete = $this->getAddresss(new Criteria(), $con)->diff($addresss); - - $this->addresssScheduledForDeletion = unserialize(serialize($addresssToDelete)); - - foreach ($addresssToDelete as $addressRemoved) { - $addressRemoved->setCustomerTitle(null); - } - - $this->collAddresss = null; - foreach ($addresss as $address) { - $this->addAddress($address); - } - - $this->collAddresss = $addresss; - $this->collAddresssPartial = false; - - return $this; - } - - /** - * Returns the number of related Address objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Address objects. - * @throws PropelException - */ - public function countAddresss(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAddresssPartial && !$this->isNew(); - if (null === $this->collAddresss || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAddresss) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAddresss()); - } - $query = AddressQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); - } - - return count($this->collAddresss); - } - - /** - * Method called to associate a Address object to this object - * through the Address foreign key attribute. - * - * @param Address $l Address - * @return CustomerTitle The current object (for fluent API support) - */ - public function addAddress(Address $l) - { - if ($this->collAddresss === null) { - $this->initAddresss(); - $this->collAddresssPartial = true; - } - if (!in_array($l, $this->collAddresss->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAddress($l); - } - - return $this; - } - - /** - * @param Address $address The address object to add. - */ - protected function doAddAddress($address) - { - $this->collAddresss[]= $address; - $address->setCustomerTitle($this); - } - - /** - * @param Address $address The address object to remove. - * @return CustomerTitle The current object (for fluent API support) - */ - public function removeAddress($address) - { - if ($this->getAddresss()->contains($address)) { - $this->collAddresss->remove($this->collAddresss->search($address)); - if (null === $this->addresssScheduledForDeletion) { - $this->addresssScheduledForDeletion = clone $this->collAddresss; - $this->addresssScheduledForDeletion->clear(); - } - $this->addresssScheduledForDeletion[]= $address; - $address->setCustomerTitle(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this CustomerTitle is new, it will return - * an empty collection; or if this CustomerTitle has previously - * been saved, it will retrieve related Addresss from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in CustomerTitle. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Address[] List of Address objects - */ - public function getAddresssJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AddressQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); - - return $this->getAddresss($query, $con); - } - - /** - * Clears out the collCustomerTitleI18ns 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 CustomerTitle The current object (for fluent API support) - * @see addCustomerTitleI18ns() - */ - public function clearCustomerTitleI18ns() - { - $this->collCustomerTitleI18ns = null; // important to set this to null since that means it is uninitialized - $this->collCustomerTitleI18nsPartial = null; - - return $this; - } - - /** - * reset is the collCustomerTitleI18ns collection loaded partially - * - * @return void - */ - public function resetPartialCustomerTitleI18ns($v = true) - { - $this->collCustomerTitleI18nsPartial = $v; - } - - /** - * Initializes the collCustomerTitleI18ns collection. - * - * By default this just sets the collCustomerTitleI18ns collection to an empty array (like clearcollCustomerTitleI18ns()); - * 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 initCustomerTitleI18ns($overrideExisting = true) - { - if (null !== $this->collCustomerTitleI18ns && !$overrideExisting) { - return; - } - $this->collCustomerTitleI18ns = new PropelObjectCollection(); - $this->collCustomerTitleI18ns->setModel('CustomerTitleI18n'); - } - - /** - * Gets an array of CustomerTitleI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this CustomerTitle is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CustomerTitleI18n[] List of CustomerTitleI18n objects - * @throws PropelException - */ - public function getCustomerTitleI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew(); - if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomerTitleI18ns) { - // return empty collection - $this->initCustomerTitleI18ns(); - } else { - $collCustomerTitleI18ns = CustomerTitleI18nQuery::create(null, $criteria) - ->filterByCustomerTitle($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCustomerTitleI18nsPartial && count($collCustomerTitleI18ns)) { - $this->initCustomerTitleI18ns(false); - - foreach($collCustomerTitleI18ns as $obj) { - if (false == $this->collCustomerTitleI18ns->contains($obj)) { - $this->collCustomerTitleI18ns->append($obj); - } - } - - $this->collCustomerTitleI18nsPartial = true; - } - - $collCustomerTitleI18ns->getInternalIterator()->rewind(); - return $collCustomerTitleI18ns; - } - - if($partial && $this->collCustomerTitleI18ns) { - foreach($this->collCustomerTitleI18ns as $obj) { - if($obj->isNew()) { - $collCustomerTitleI18ns[] = $obj; - } - } - } - - $this->collCustomerTitleI18ns = $collCustomerTitleI18ns; - $this->collCustomerTitleI18nsPartial = false; - } - } - - return $this->collCustomerTitleI18ns; - } - - /** - * Sets a collection of CustomerTitleI18n 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 $customerTitleI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return CustomerTitle The current object (for fluent API support) - */ - public function setCustomerTitleI18ns(PropelCollection $customerTitleI18ns, PropelPDO $con = null) - { - $customerTitleI18nsToDelete = $this->getCustomerTitleI18ns(new Criteria(), $con)->diff($customerTitleI18ns); - - $this->customerTitleI18nsScheduledForDeletion = unserialize(serialize($customerTitleI18nsToDelete)); - - foreach ($customerTitleI18nsToDelete as $customerTitleI18nRemoved) { - $customerTitleI18nRemoved->setCustomerTitle(null); - } - - $this->collCustomerTitleI18ns = null; - foreach ($customerTitleI18ns as $customerTitleI18n) { - $this->addCustomerTitleI18n($customerTitleI18n); - } - - $this->collCustomerTitleI18ns = $customerTitleI18ns; - $this->collCustomerTitleI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related CustomerTitleI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CustomerTitleI18n objects. - * @throws PropelException - */ - public function countCustomerTitleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCustomerTitleI18nsPartial && !$this->isNew(); - if (null === $this->collCustomerTitleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCustomerTitleI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCustomerTitleI18ns()); - } - $query = CustomerTitleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByCustomerTitle($this) - ->count($con); - } - - return count($this->collCustomerTitleI18ns); - } - - /** - * Method called to associate a CustomerTitleI18n object to this object - * through the CustomerTitleI18n foreign key attribute. - * - * @param CustomerTitleI18n $l CustomerTitleI18n - * @return CustomerTitle The current object (for fluent API support) - */ - public function addCustomerTitleI18n(CustomerTitleI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collCustomerTitleI18ns === null) { - $this->initCustomerTitleI18ns(); - $this->collCustomerTitleI18nsPartial = true; - } - if (!in_array($l, $this->collCustomerTitleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCustomerTitleI18n($l); - } - - return $this; - } - - /** - * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to add. - */ - protected function doAddCustomerTitleI18n($customerTitleI18n) - { - $this->collCustomerTitleI18ns[]= $customerTitleI18n; - $customerTitleI18n->setCustomerTitle($this); - } - - /** - * @param CustomerTitleI18n $customerTitleI18n The customerTitleI18n object to remove. - * @return CustomerTitle The current object (for fluent API support) - */ - public function removeCustomerTitleI18n($customerTitleI18n) - { - if ($this->getCustomerTitleI18ns()->contains($customerTitleI18n)) { - $this->collCustomerTitleI18ns->remove($this->collCustomerTitleI18ns->search($customerTitleI18n)); - if (null === $this->customerTitleI18nsScheduledForDeletion) { - $this->customerTitleI18nsScheduledForDeletion = clone $this->collCustomerTitleI18ns; - $this->customerTitleI18nsScheduledForDeletion->clear(); - } - $this->customerTitleI18nsScheduledForDeletion[]= clone $customerTitleI18n; - $customerTitleI18n->setCustomerTitle(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->by_default = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collCustomers) { - foreach ($this->collCustomers as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAddresss) { - foreach ($this->collAddresss as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCustomerTitleI18ns) { - foreach ($this->collCustomerTitleI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collCustomers instanceof PropelCollection) { - $this->collCustomers->clearIterator(); - } - $this->collCustomers = null; - if ($this->collAddresss instanceof PropelCollection) { - $this->collAddresss->clearIterator(); - } - $this->collAddresss = null; - if ($this->collCustomerTitleI18ns instanceof PropelCollection) { - $this->collCustomerTitleI18ns->clearIterator(); - } - $this->collCustomerTitleI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CustomerTitlePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return CustomerTitle The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = CustomerTitlePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return CustomerTitle The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return CustomerTitleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collCustomerTitleI18ns) { - foreach ($this->collCustomerTitleI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new CustomerTitleI18n(); - $translation->setLocale($locale); - } else { - $translation = CustomerTitleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addCustomerTitleI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return CustomerTitle The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - CustomerTitleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collCustomerTitleI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collCustomerTitleI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return CustomerTitleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [short] column value. - * - * @return string - */ - public function getShort() - { - return $this->getCurrentTranslation()->getShort(); - } - - - /** - * Set the value of [short] column. - * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setShort($v) - { $this->getCurrentTranslation()->setShort($v); - - return $this; - } - - - /** - * Get the [long] column value. - * - * @return string - */ - public function getLong() - { - return $this->getCurrentTranslation()->getLong(); - } - - - /** - * Set the value of [long] column. - * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setLong($v) - { $this->getCurrentTranslation()->setLong($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php deleted file mode 100755 index 0f1cf83e0..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18n.php +++ /dev/null @@ -1,1077 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseCustomerTitleI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [short] column value. - * - * @return string - */ - public function getShort() - { - return $this->short; - } - - /** - * Get the [long] column value. - * - * @return string - */ - public function getLong() - { - return $this->long; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = CustomerTitleI18nPeer::ID; - } - - if ($this->aCustomerTitle !== null && $this->aCustomerTitle->getId() !== $v) { - $this->aCustomerTitle = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = CustomerTitleI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [short] column. - * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setShort($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->short !== $v) { - $this->short = $v; - $this->modifiedColumns[] = CustomerTitleI18nPeer::SHORT; - } - - - return $this; - } // setShort() - - /** - * Set the value of [long] column. - * - * @param string $v new value - * @return CustomerTitleI18n The current object (for fluent API support) - */ - public function setLong($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->long !== $v) { - $this->long = $v; - $this->modifiedColumns[] = CustomerTitleI18nPeer::LONG; - } - - - return $this; - } // setLong() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->short = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->long = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating CustomerTitleI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCustomerTitle !== null && $this->id !== $this->aCustomerTitle->getId()) { - $this->aCustomerTitle = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::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 = CustomerTitleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCustomerTitle = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = CustomerTitleI18nQuery::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(CustomerTitleI18nPeer::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); - CustomerTitleI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomerTitle !== null) { - if ($this->aCustomerTitle->isModified() || $this->aCustomerTitle->isNew()) { - $affectedRows += $this->aCustomerTitle->save($con); - } - $this->setCustomerTitle($this->aCustomerTitle); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(CustomerTitleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(CustomerTitleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(CustomerTitleI18nPeer::SHORT)) { - $modifiedColumns[':p' . $index++] = '`short`'; - } - if ($this->isColumnModified(CustomerTitleI18nPeer::LONG)) { - $modifiedColumns[':p' . $index++] = '`long`'; - } - - $sql = sprintf( - 'INSERT INTO `customer_title_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`short`': - $stmt->bindValue($identifier, $this->short, PDO::PARAM_STR); - break; - case '`long`': - $stmt->bindValue($identifier, $this->long, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCustomerTitle !== null) { - if (!$this->aCustomerTitle->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCustomerTitle->getValidationFailures()); - } - } - - - if (($retval = CustomerTitleI18nPeer::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 = CustomerTitleI18nPeer::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->getLocale(); - break; - case 2: - return $this->getShort(); - break; - case 3: - return $this->getLong(); - 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['CustomerTitleI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['CustomerTitleI18n'][serialize($this->getPrimaryKey())] = true; - $keys = CustomerTitleI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getShort(), - $keys[3] => $this->getLong(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCustomerTitle) { - $result['CustomerTitle'] = $this->aCustomerTitle->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = CustomerTitleI18nPeer::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->setLocale($value); - break; - case 2: - $this->setShort($value); - break; - case 3: - $this->setLong($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 = CustomerTitleI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setShort($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setLong($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(CustomerTitleI18nPeer::ID)) $criteria->add(CustomerTitleI18nPeer::ID, $this->id); - if ($this->isColumnModified(CustomerTitleI18nPeer::LOCALE)) $criteria->add(CustomerTitleI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(CustomerTitleI18nPeer::SHORT)) $criteria->add(CustomerTitleI18nPeer::SHORT, $this->short); - if ($this->isColumnModified(CustomerTitleI18nPeer::LONG)) $criteria->add(CustomerTitleI18nPeer::LONG, $this->long); - - 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(CustomerTitleI18nPeer::DATABASE_NAME); - $criteria->add(CustomerTitleI18nPeer::ID, $this->id); - $criteria->add(CustomerTitleI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 CustomerTitleI18n (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->setLocale($this->getLocale()); - $copyObj->setShort($this->getShort()); - $copyObj->setLong($this->getLong()); - - 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 CustomerTitleI18n 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 CustomerTitleI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new CustomerTitleI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a CustomerTitle object. - * - * @param CustomerTitle $v - * @return CustomerTitleI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomerTitle(CustomerTitle $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aCustomerTitle = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the CustomerTitle object, it will not be re-added. - if ($v !== null) { - $v->addCustomerTitleI18n($this); - } - - - return $this; - } - - - /** - * Get the associated CustomerTitle object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return CustomerTitle The associated CustomerTitle object. - * @throws PropelException - */ - public function getCustomerTitle(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCustomerTitle === null && ($this->id !== null) && $doQuery) { - $this->aCustomerTitle = CustomerTitleQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomerTitle->addCustomerTitleI18ns($this); - */ - } - - return $this->aCustomerTitle; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->short = null; - $this->long = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCustomerTitle instanceof Persistent) { - $this->aCustomerTitle->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCustomerTitle = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(CustomerTitleI18nPeer::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/BaseCustomerTitleI18nPeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php deleted file mode 100755 index 93a40f1a4..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nPeer.php +++ /dev/null @@ -1,1006 +0,0 @@ - array ('Id', 'Locale', 'Short', 'Long', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'short', 'long', ), - BasePeer::TYPE_COLNAME => array (CustomerTitleI18nPeer::ID, CustomerTitleI18nPeer::LOCALE, CustomerTitleI18nPeer::SHORT, CustomerTitleI18nPeer::LONG, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'SHORT', 'LONG', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'short', 'long', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CustomerTitleI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Short' => 2, 'Long' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ), - BasePeer::TYPE_COLNAME => array (CustomerTitleI18nPeer::ID => 0, CustomerTitleI18nPeer::LOCALE => 1, CustomerTitleI18nPeer::SHORT => 2, CustomerTitleI18nPeer::LONG => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'SHORT' => 2, 'LONG' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'short' => 2, 'long' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CustomerTitleI18nPeer::getFieldNames($toType); - $key = isset(CustomerTitleI18nPeer::$fieldKeys[$fromType][$name]) ? CustomerTitleI18nPeer::$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(CustomerTitleI18nPeer::$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, CustomerTitleI18nPeer::$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 CustomerTitleI18nPeer::$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. CustomerTitleI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::ID); - $criteria->addSelectColumn(CustomerTitleI18nPeer::LOCALE); - $criteria->addSelectColumn(CustomerTitleI18nPeer::SHORT); - $criteria->addSelectColumn(CustomerTitleI18nPeer::LONG); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.short'); - $criteria->addSelectColumn($alias . '.long'); - } - } - - /** - * 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(CustomerTitleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerTitleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::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 CustomerTitleI18n - * @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 = CustomerTitleI18nPeer::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 CustomerTitleI18nPeer::populateObjects(CustomerTitleI18nPeer::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 directly (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(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CustomerTitleI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::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 CustomerTitleI18n $obj A CustomerTitleI18n 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->getLocale())); - } // if key === null - CustomerTitleI18nPeer::$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 CustomerTitleI18n 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 CustomerTitleI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 CustomerTitleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CustomerTitleI18nPeer::$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 CustomerTitleI18n 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(CustomerTitleI18nPeer::$instances[$key])) { - return CustomerTitleI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CustomerTitleI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CustomerTitleI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to customer_title_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CustomerTitleI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CustomerTitleI18nPeer::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; - CustomerTitleI18nPeer::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 (CustomerTitleI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CustomerTitleI18nPeer::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 + CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CustomerTitleI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CustomerTitleI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related CustomerTitle table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCustomerTitle(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerTitleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of CustomerTitleI18n objects pre-filled with their CustomerTitle objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of CustomerTitleI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCustomerTitle(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); - } - - CustomerTitleI18nPeer::addSelectColumns($criteria); - $startcol = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS; - CustomerTitlePeer::addSelectColumns($criteria); - - $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CustomerTitleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = CustomerTitleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CustomerTitleI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (CustomerTitleI18n) to $obj2 (CustomerTitle) - $obj2->addCustomerTitleI18n($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(CustomerTitleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerTitleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of CustomerTitleI18n 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 CustomerTitleI18n 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(CustomerTitleI18nPeer::DATABASE_NAME); - } - - CustomerTitleI18nPeer::addSelectColumns($criteria); - $startcol2 = CustomerTitleI18nPeer::NUM_HYDRATE_COLUMNS; - - CustomerTitlePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerTitlePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(CustomerTitleI18nPeer::ID, CustomerTitlePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = CustomerTitleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = CustomerTitleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = CustomerTitleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - CustomerTitleI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined CustomerTitle rows - - $key2 = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerTitlePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerTitlePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerTitlePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (CustomerTitleI18n) to the collection in $obj2 (CustomerTitle) - $obj2->addCustomerTitleI18n($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(CustomerTitleI18nPeer::DATABASE_NAME)->getTable(CustomerTitleI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCustomerTitleI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCustomerTitleI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new CustomerTitleI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CustomerTitleI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CustomerTitleI18n or Criteria object. - * - * @param mixed $values Criteria or CustomerTitleI18n 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(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CustomerTitleI18n object - } - - - // Set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::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 CustomerTitleI18n or Criteria object. - * - * @param mixed $values Criteria or CustomerTitleI18n 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(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CustomerTitleI18nPeer::ID); - $value = $criteria->remove(CustomerTitleI18nPeer::ID); - if ($value) { - $selectCriteria->add(CustomerTitleI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(CustomerTitleI18nPeer::LOCALE); - $value = $criteria->remove(CustomerTitleI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(CustomerTitleI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CustomerTitleI18nPeer::TABLE_NAME); - } - - } else { // $values is CustomerTitleI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the customer_title_i18n 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(CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::TABLE_NAME, $con, CustomerTitleI18nPeer::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). - CustomerTitleI18nPeer::clearInstancePool(); - CustomerTitleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CustomerTitleI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CustomerTitleI18n 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(CustomerTitleI18nPeer::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. - CustomerTitleI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CustomerTitleI18n) { // it's a model object - // invalidate the cache for this single object - CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(CustomerTitleI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - CustomerTitleI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(CustomerTitleI18nPeer::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); - CustomerTitleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CustomerTitleI18n 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 CustomerTitleI18n $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(CustomerTitleI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::DATABASE_NAME, CustomerTitleI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return CustomerTitleI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = CustomerTitleI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(CustomerTitleI18nPeer::DATABASE_NAME); - $criteria->add(CustomerTitleI18nPeer::ID, $id); - $criteria->add(CustomerTitleI18nPeer::LOCALE, $locale); - $v = CustomerTitleI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseCustomerTitleI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCustomerTitleI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php deleted file mode 100755 index 027989714..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleI18nQuery.php +++ /dev/null @@ -1,471 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return CustomerTitleI18n|CustomerTitleI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CustomerTitleI18nPeer::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(CustomerTitleI18nPeer::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 CustomerTitleI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `short`, `long` FROM `customer_title_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 CustomerTitleI18n(); - $obj->hydrate($row); - CustomerTitleI18nPeer::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 CustomerTitleI18n|CustomerTitleI18n[]|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|CustomerTitleI18n[]|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 CustomerTitleI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(CustomerTitleI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(CustomerTitleI18nPeer::LOCALE, $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 CustomerTitleI18nQuery 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(CustomerTitleI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(CustomerTitleI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByCustomerTitle() - * - * @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 CustomerTitleI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTitleI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 CustomerTitleI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTitleI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the short column - * - * Example usage: - * - * $query->filterByShort('fooValue'); // WHERE short = 'fooValue' - * $query->filterByShort('%fooValue%'); // WHERE short LIKE '%fooValue%' - * - * - * @param string $short The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleI18nQuery The current query, for fluid interface - */ - public function filterByShort($short = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($short)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $short)) { - $short = str_replace('*', '%', $short); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTitleI18nPeer::SHORT, $short, $comparison); - } - - /** - * Filter the query on the long column - * - * Example usage: - * - * $query->filterByLong('fooValue'); // WHERE long = 'fooValue' - * $query->filterByLong('%fooValue%'); // WHERE long LIKE '%fooValue%' - * - * - * @param string $long The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleI18nQuery The current query, for fluid interface - */ - public function filterByLong($long = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($long)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $long)) { - $long = str_replace('*', '%', $long); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTitleI18nPeer::LONG, $long, $comparison); - } - - /** - * Filter the query by a related CustomerTitle object - * - * @param CustomerTitle|PropelObjectCollection $customerTitle The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomerTitle($customerTitle, $comparison = null) - { - if ($customerTitle instanceof CustomerTitle) { - return $this - ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->getId(), $comparison); - } elseif ($customerTitle instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(CustomerTitleI18nPeer::ID, $customerTitle->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomerTitle() only accepts arguments of type CustomerTitle or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CustomerTitle relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerTitleI18nQuery The current query, for fluid interface - */ - public function joinCustomerTitle($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CustomerTitle'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CustomerTitle'); - } - - return $this; - } - - /** - * Use the CustomerTitle relation CustomerTitle object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerTitleQuery A secondary query class using the current class as primary query - */ - public function useCustomerTitleQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCustomerTitle($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitle', '\Thelia\Model\CustomerTitleQuery'); - } - - /** - * Exclude object from result - * - * @param CustomerTitleI18n $customerTitleI18n Object to remove from the list of results - * - * @return CustomerTitleI18nQuery The current query, for fluid interface - */ - public function prune($customerTitleI18n = null) - { - if ($customerTitleI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(CustomerTitleI18nPeer::ID), $customerTitleI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(CustomerTitleI18nPeer::LOCALE), $customerTitleI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php b/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php deleted file mode 100755 index ef52d8a06..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitlePeer.php +++ /dev/null @@ -1,805 +0,0 @@ - array ('Id', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID, CustomerTitlePeer::BY_DEFAULT, CustomerTitlePeer::POSITION, CustomerTitlePeer::CREATED_AT, CustomerTitlePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'by_default', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. CustomerTitlePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ByDefault' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'byDefault' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (CustomerTitlePeer::ID => 0, CustomerTitlePeer::BY_DEFAULT => 1, CustomerTitlePeer::POSITION => 2, CustomerTitlePeer::CREATED_AT => 3, CustomerTitlePeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'BY_DEFAULT' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'by_default' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = CustomerTitlePeer::getFieldNames($toType); - $key = isset(CustomerTitlePeer::$fieldKeys[$fromType][$name]) ? CustomerTitlePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(CustomerTitlePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, CustomerTitlePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return CustomerTitlePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. CustomerTitlePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(CustomerTitlePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(CustomerTitlePeer::ID); - $criteria->addSelectColumn(CustomerTitlePeer::BY_DEFAULT); - $criteria->addSelectColumn(CustomerTitlePeer::POSITION); - $criteria->addSelectColumn(CustomerTitlePeer::CREATED_AT); - $criteria->addSelectColumn(CustomerTitlePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.by_default'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - CustomerTitlePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return CustomerTitle - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = CustomerTitlePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return CustomerTitlePeer::populateObjects(CustomerTitlePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - CustomerTitlePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param CustomerTitle $obj A CustomerTitle object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - CustomerTitlePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A CustomerTitle object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof CustomerTitle) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CustomerTitle object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(CustomerTitlePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return CustomerTitle Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(CustomerTitlePeer::$instances[$key])) { - return CustomerTitlePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (CustomerTitlePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - CustomerTitlePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to customer_title - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in CustomerPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CustomerPeer::clearInstancePool(); - // Invalidate objects in CustomerTitleI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CustomerTitleI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = CustomerTitlePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - CustomerTitlePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (CustomerTitle object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = CustomerTitlePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + CustomerTitlePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = CustomerTitlePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - CustomerTitlePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(CustomerTitlePeer::DATABASE_NAME)->getTable(CustomerTitlePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseCustomerTitlePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseCustomerTitlePeer::TABLE_NAME)) { - $dbMap->addTableObject(new CustomerTitleTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return CustomerTitlePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a CustomerTitle or Criteria object. - * - * @param mixed $values Criteria or CustomerTitle object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from CustomerTitle object - } - - if ($criteria->containsKey(CustomerTitlePeer::ID) && $criteria->keyContainsValue(CustomerTitlePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.CustomerTitlePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a CustomerTitle or Criteria object. - * - * @param mixed $values Criteria or CustomerTitle object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(CustomerTitlePeer::ID); - $value = $criteria->remove(CustomerTitlePeer::ID); - if ($value) { - $selectCriteria->add(CustomerTitlePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(CustomerTitlePeer::TABLE_NAME); - } - - } else { // $values is CustomerTitle object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the customer_title table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(CustomerTitlePeer::TABLE_NAME, $con, CustomerTitlePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - CustomerTitlePeer::clearInstancePool(); - CustomerTitlePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a CustomerTitle or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or CustomerTitle object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - CustomerTitlePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof CustomerTitle) { // it's a model object - // invalidate the cache for this single object - CustomerTitlePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - $criteria->add(CustomerTitlePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - CustomerTitlePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(CustomerTitlePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - CustomerTitlePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given CustomerTitle object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param CustomerTitle $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(CustomerTitlePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(CustomerTitlePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(CustomerTitlePeer::DATABASE_NAME, CustomerTitlePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return CustomerTitle - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = CustomerTitlePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - $criteria->add(CustomerTitlePeer::ID, $pk); - - $v = CustomerTitlePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return CustomerTitle[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(CustomerTitlePeer::DATABASE_NAME); - $criteria->add(CustomerTitlePeer::ID, $pks, Criteria::IN); - $objs = CustomerTitlePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseCustomerTitlePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseCustomerTitlePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php b/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php deleted file mode 100755 index d35f91f22..000000000 --- a/core/lib/Thelia/Model/om/BaseCustomerTitleQuery.php +++ /dev/null @@ -1,819 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = CustomerTitlePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(CustomerTitlePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CustomerTitle A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CustomerTitle A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `by_default`, `position`, `created_at`, `updated_at` FROM `customer_title` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new CustomerTitle(); - $obj->hydrate($row); - CustomerTitlePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return CustomerTitle|CustomerTitle[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|CustomerTitle[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(CustomerTitlePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(CustomerTitlePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(CustomerTitlePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(CustomerTitlePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTitlePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the by_default column - * - * Example usage: - * - * $query->filterByByDefault(1234); // WHERE by_default = 1234 - * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 - * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 - * - * - * @param mixed $byDefault The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByByDefault($byDefault = null, $comparison = null) - { - if (is_array($byDefault)) { - $useMinMax = false; - if (isset($byDefault['min'])) { - $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($byDefault['max'])) { - $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTitlePeer::BY_DEFAULT, $byDefault, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition('fooValue'); // WHERE position = 'fooValue' - * $query->filterByPosition('%fooValue%'); // WHERE position LIKE '%fooValue%' - * - * - * @param string $position The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($position)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $position)) { - $position = str_replace('*', '%', $position); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(CustomerTitlePeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Customer object - * - * @param Customer|PropelObjectCollection $customer the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomer($customer, $comparison = null) - { - if ($customer instanceof Customer) { - return $this - ->addUsingAlias(CustomerTitlePeer::ID, $customer->getCustomerTitleId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { - return $this - ->useCustomerQuery() - ->filterByPrimaryKeys($customer->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Customer relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinCustomer($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Customer'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Customer'); - } - - return $this; - } - - /** - * Use the Customer relation Customer object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query - */ - public function useCustomerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCustomer($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); - } - - /** - * Filter the query by a related Address object - * - * @param Address|PropelObjectCollection $address the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAddress($address, $comparison = null) - { - if ($address instanceof Address) { - return $this - ->addUsingAlias(CustomerTitlePeer::ID, $address->getCustomerTitleId(), $comparison); - } elseif ($address instanceof PropelObjectCollection) { - return $this - ->useAddressQuery() - ->filterByPrimaryKeys($address->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAddress() only accepts arguments of type Address or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Address relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinAddress($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Address'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Address'); - } - - return $this; - } - - /** - * Use the Address relation Address object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AddressQuery A secondary query class using the current class as primary query - */ - public function useAddressQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinAddress($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Address', '\Thelia\Model\AddressQuery'); - } - - /** - * Filter the query by a related CustomerTitleI18n object - * - * @param CustomerTitleI18n|PropelObjectCollection $customerTitleI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return CustomerTitleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomerTitleI18n($customerTitleI18n, $comparison = null) - { - if ($customerTitleI18n instanceof CustomerTitleI18n) { - return $this - ->addUsingAlias(CustomerTitlePeer::ID, $customerTitleI18n->getId(), $comparison); - } elseif ($customerTitleI18n instanceof PropelObjectCollection) { - return $this - ->useCustomerTitleI18nQuery() - ->filterByPrimaryKeys($customerTitleI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCustomerTitleI18n() only accepts arguments of type CustomerTitleI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CustomerTitleI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinCustomerTitleI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CustomerTitleI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CustomerTitleI18n'); - } - - return $this; - } - - /** - * Use the CustomerTitleI18n relation CustomerTitleI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerTitleI18nQuery A secondary query class using the current class as primary query - */ - public function useCustomerTitleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinCustomerTitleI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', '\Thelia\Model\CustomerTitleI18nQuery'); - } - - /** - * Exclude object from result - * - * @param CustomerTitle $customerTitle Object to remove from the list of results - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function prune($customerTitle = null) - { - if ($customerTitle) { - $this->addUsingAlias(CustomerTitlePeer::ID, $customerTitle->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(CustomerTitlePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(CustomerTitlePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(CustomerTitlePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(CustomerTitlePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(CustomerTitlePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(CustomerTitlePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; - - return $this - ->joinCustomerTitleI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CustomerTitleQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('CustomerTitleI18n'); - $this->with['CustomerTitleI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return CustomerTitleI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CustomerTitleI18n', 'Thelia\Model\CustomerTitleI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseDelivzone.php b/core/lib/Thelia/Model/om/BaseDelivzone.php deleted file mode 100755 index 0e19dcde3..000000000 --- a/core/lib/Thelia/Model/om/BaseDelivzone.php +++ /dev/null @@ -1,1200 +0,0 @@ -id; - } - - /** - * Get the [area_id] column value. - * - * @return int - */ - public function getAreaId() - { - return $this->area_id; - } - - /** - * Get the [delivery] column value. - * - * @return string - */ - public function getDelivery() - { - return $this->delivery; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Delivzone The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = DelivzonePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [area_id] column. - * - * @param int $v new value - * @return Delivzone The current object (for fluent API support) - */ - public function setAreaId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->area_id !== $v) { - $this->area_id = $v; - $this->modifiedColumns[] = DelivzonePeer::AREA_ID; - } - - if ($this->aArea !== null && $this->aArea->getId() !== $v) { - $this->aArea = null; - } - - - return $this; - } // setAreaId() - - /** - * Set the value of [delivery] column. - * - * @param string $v new value - * @return Delivzone The current object (for fluent API support) - */ - public function setDelivery($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->delivery !== $v) { - $this->delivery = $v; - $this->modifiedColumns[] = DelivzonePeer::DELIVERY; - } - - - return $this; - } // setDelivery() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Delivzone The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = DelivzonePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Delivzone The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = DelivzonePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->area_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->delivery = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = DelivzonePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Delivzone object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { - $this->aArea = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = DelivzonePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aArea = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = DelivzoneQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(DelivzonePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(DelivzonePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DelivzonePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - DelivzonePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aArea !== null) { - if ($this->aArea->isModified() || $this->aArea->isNew()) { - $affectedRows += $this->aArea->save($con); - } - $this->setArea($this->aArea); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = DelivzonePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DelivzonePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DelivzonePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(DelivzonePeer::AREA_ID)) { - $modifiedColumns[':p' . $index++] = '`area_id`'; - } - if ($this->isColumnModified(DelivzonePeer::DELIVERY)) { - $modifiedColumns[':p' . $index++] = '`delivery`'; - } - if ($this->isColumnModified(DelivzonePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(DelivzonePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `delivzone` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`area_id`': - $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); - break; - case '`delivery`': - $stmt->bindValue($identifier, $this->delivery, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aArea !== null) { - if (!$this->aArea->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aArea->getValidationFailures()); - } - } - - - if (($retval = DelivzonePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = DelivzonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getAreaId(); - break; - case 2: - return $this->getDelivery(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Delivzone'][$this->getPrimaryKey()] = true; - $keys = DelivzonePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getAreaId(), - $keys[2] => $this->getDelivery(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aArea) { - $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = DelivzonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setAreaId($value); - break; - case 2: - $this->setDelivery($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = DelivzonePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setAreaId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setDelivery($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(DelivzonePeer::DATABASE_NAME); - - if ($this->isColumnModified(DelivzonePeer::ID)) $criteria->add(DelivzonePeer::ID, $this->id); - if ($this->isColumnModified(DelivzonePeer::AREA_ID)) $criteria->add(DelivzonePeer::AREA_ID, $this->area_id); - if ($this->isColumnModified(DelivzonePeer::DELIVERY)) $criteria->add(DelivzonePeer::DELIVERY, $this->delivery); - if ($this->isColumnModified(DelivzonePeer::CREATED_AT)) $criteria->add(DelivzonePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DelivzonePeer::UPDATED_AT)) $criteria->add(DelivzonePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(DelivzonePeer::DATABASE_NAME); - $criteria->add(DelivzonePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Delivzone (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setAreaId($this->getAreaId()); - $copyObj->setDelivery($this->getDelivery()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Delivzone Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return DelivzonePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new DelivzonePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Area object. - * - * @param Area $v - * @return Delivzone The current object (for fluent API support) - * @throws PropelException - */ - public function setArea(Area $v = null) - { - if ($v === null) { - $this->setAreaId(NULL); - } else { - $this->setAreaId($v->getId()); - } - - $this->aArea = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Area object, it will not be re-added. - if ($v !== null) { - $v->addDelivzone($this); - } - - - return $this; - } - - - /** - * Get the associated Area object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Area The associated Area object. - * @throws PropelException - */ - public function getArea(PropelPDO $con = null, $doQuery = true) - { - if ($this->aArea === null && ($this->area_id !== null) && $doQuery) { - $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aArea->addDelivzones($this); - */ - } - - return $this->aArea; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->area_id = null; - $this->delivery = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aArea instanceof Persistent) { - $this->aArea->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aArea = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(DelivzonePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Delivzone The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = DelivzonePeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php b/core/lib/Thelia/Model/om/BaseDelivzonePeer.php deleted file mode 100755 index 51f1d1b54..000000000 --- a/core/lib/Thelia/Model/om/BaseDelivzonePeer.php +++ /dev/null @@ -1,1029 +0,0 @@ - array ('Id', 'AreaId', 'Delivery', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'areaId', 'delivery', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (DelivzonePeer::ID, DelivzonePeer::AREA_ID, DelivzonePeer::DELIVERY, DelivzonePeer::CREATED_AT, DelivzonePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'AREA_ID', 'DELIVERY', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'area_id', 'delivery', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. DelivzonePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'AreaId' => 1, 'Delivery' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'areaId' => 1, 'delivery' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (DelivzonePeer::ID => 0, DelivzonePeer::AREA_ID => 1, DelivzonePeer::DELIVERY => 2, DelivzonePeer::CREATED_AT => 3, DelivzonePeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'AREA_ID' => 1, 'DELIVERY' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'area_id' => 1, 'delivery' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = DelivzonePeer::getFieldNames($toType); - $key = isset(DelivzonePeer::$fieldKeys[$fromType][$name]) ? DelivzonePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(DelivzonePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, DelivzonePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return DelivzonePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. DelivzonePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(DelivzonePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(DelivzonePeer::ID); - $criteria->addSelectColumn(DelivzonePeer::AREA_ID); - $criteria->addSelectColumn(DelivzonePeer::DELIVERY); - $criteria->addSelectColumn(DelivzonePeer::CREATED_AT); - $criteria->addSelectColumn(DelivzonePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.area_id'); - $criteria->addSelectColumn($alias . '.delivery'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DelivzonePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Delivzone - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = DelivzonePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return DelivzonePeer::populateObjects(DelivzonePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - DelivzonePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Delivzone $obj A Delivzone object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - DelivzonePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Delivzone object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Delivzone) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Delivzone object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(DelivzonePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Delivzone Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(DelivzonePeer::$instances[$key])) { - return DelivzonePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (DelivzonePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - DelivzonePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to delivzone - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = DelivzonePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = DelivzonePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - DelivzonePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Delivzone object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = DelivzonePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = DelivzonePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + DelivzonePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = DelivzonePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - DelivzonePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Area table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinArea(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DelivzonePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Delivzone objects pre-filled with their Area objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Delivzone objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinArea(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - } - - DelivzonePeer::addSelectColumns($criteria); - $startcol = DelivzonePeer::NUM_HYDRATE_COLUMNS; - AreaPeer::addSelectColumns($criteria); - - $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DelivzonePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DelivzonePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DelivzonePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = AreaPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AreaPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - AreaPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Delivzone) to $obj2 (Area) - $obj2->addDelivzone($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DelivzonePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Delivzone objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Delivzone objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - } - - DelivzonePeer::addSelectColumns($criteria); - $startcol2 = DelivzonePeer::NUM_HYDRATE_COLUMNS; - - AreaPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + AreaPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DelivzonePeer::AREA_ID, AreaPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DelivzonePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DelivzonePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DelivzonePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DelivzonePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Area rows - - $key2 = AreaPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = AreaPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = AreaPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - AreaPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Delivzone) to the collection in $obj2 (Area) - $obj2->addDelivzone($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(DelivzonePeer::DATABASE_NAME)->getTable(DelivzonePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseDelivzonePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseDelivzonePeer::TABLE_NAME)) { - $dbMap->addTableObject(new DelivzoneTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return DelivzonePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Delivzone or Criteria object. - * - * @param mixed $values Criteria or Delivzone object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Delivzone object - } - - if ($criteria->containsKey(DelivzonePeer::ID) && $criteria->keyContainsValue(DelivzonePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DelivzonePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Delivzone or Criteria object. - * - * @param mixed $values Criteria or Delivzone object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(DelivzonePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(DelivzonePeer::ID); - $value = $criteria->remove(DelivzonePeer::ID); - if ($value) { - $selectCriteria->add(DelivzonePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(DelivzonePeer::TABLE_NAME); - } - - } else { // $values is Delivzone object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the delivzone table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(DelivzonePeer::TABLE_NAME, $con, DelivzonePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - DelivzonePeer::clearInstancePool(); - DelivzonePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Delivzone or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Delivzone object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - DelivzonePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Delivzone) { // it's a model object - // invalidate the cache for this single object - DelivzonePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DelivzonePeer::DATABASE_NAME); - $criteria->add(DelivzonePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - DelivzonePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(DelivzonePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - DelivzonePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Delivzone object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Delivzone $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(DelivzonePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(DelivzonePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(DelivzonePeer::DATABASE_NAME, DelivzonePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Delivzone - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = DelivzonePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(DelivzonePeer::DATABASE_NAME); - $criteria->add(DelivzonePeer::ID, $pk); - - $v = DelivzonePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Delivzone[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(DelivzonePeer::DATABASE_NAME); - $criteria->add(DelivzonePeer::ID, $pks, Criteria::IN); - $objs = DelivzonePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseDelivzonePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseDelivzonePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php b/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php deleted file mode 100755 index 93f87df2c..000000000 --- a/core/lib/Thelia/Model/om/BaseDelivzoneQuery.php +++ /dev/null @@ -1,608 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = DelivzonePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(DelivzonePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Delivzone A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Delivzone A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `area_id`, `delivery`, `created_at`, `updated_at` FROM `delivzone` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Delivzone(); - $obj->hydrate($row); - DelivzonePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Delivzone|Delivzone[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Delivzone[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(DelivzonePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(DelivzonePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(DelivzonePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(DelivzonePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzonePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the area_id column - * - * Example usage: - * - * $query->filterByAreaId(1234); // WHERE area_id = 1234 - * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) - * $query->filterByAreaId(array('min' => 12)); // WHERE area_id >= 12 - * $query->filterByAreaId(array('max' => 12)); // WHERE area_id <= 12 - * - * - * @see filterByArea() - * - * @param mixed $areaId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByAreaId($areaId = null, $comparison = null) - { - if (is_array($areaId)) { - $useMinMax = false; - if (isset($areaId['min'])) { - $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($areaId['max'])) { - $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzonePeer::AREA_ID, $areaId, $comparison); - } - - /** - * Filter the query on the delivery column - * - * Example usage: - * - * $query->filterByDelivery('fooValue'); // WHERE delivery = 'fooValue' - * $query->filterByDelivery('%fooValue%'); // WHERE delivery LIKE '%fooValue%' - * - * - * @param string $delivery The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByDelivery($delivery = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($delivery)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $delivery)) { - $delivery = str_replace('*', '%', $delivery); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DelivzonePeer::DELIVERY, $delivery, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzonePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Area object - * - * @param Area|PropelObjectCollection $area The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DelivzoneQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByArea($area, $comparison = null) - { - if ($area instanceof Area) { - return $this - ->addUsingAlias(DelivzonePeer::AREA_ID, $area->getId(), $comparison); - } elseif ($area instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DelivzonePeer::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByArea() only accepts arguments of type Area or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Area relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function joinArea($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Area'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Area'); - } - - return $this; - } - - /** - * Use the Area relation Area object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query - */ - public function useAreaQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinArea($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); - } - - /** - * Exclude object from result - * - * @param Delivzone $delivzone Object to remove from the list of results - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function prune($delivzone = null) - { - if ($delivzone) { - $this->addUsingAlias(DelivzonePeer::ID, $delivzone->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(DelivzonePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(DelivzonePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(DelivzonePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(DelivzonePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(DelivzonePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return DelivzoneQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(DelivzonePeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseDocument.php b/core/lib/Thelia/Model/om/BaseDocument.php deleted file mode 100755 index c13846285..000000000 --- a/core/lib/Thelia/Model/om/BaseDocument.php +++ /dev/null @@ -1,2193 +0,0 @@ -id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - return $this->folder_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - return $this->content_id; - } - - /** - * Get the [file] column value. - * - * @return string - */ - public function getFile() - { - return $this->file; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = DocumentPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = DocumentPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = DocumentPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = DocumentPeer::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = DocumentPeer::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Set the value of [file] column. - * - * @param string $v new value - * @return Document The current object (for fluent API support) - */ - public function setFile($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->file !== $v) { - $this->file = $v; - $this->modifiedColumns[] = DocumentPeer::FILE; - } - - - return $this; - } // setFile() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Document The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = DocumentPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Document The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = DocumentPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Document The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = DocumentPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->folder_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->content_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->file = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = DocumentPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Document object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = DocumentPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; - $this->collDocumentI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = DocumentQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(DocumentPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(DocumentPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(DocumentPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - DocumentPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->documentI18nsScheduledForDeletion !== null) { - if (!$this->documentI18nsScheduledForDeletion->isEmpty()) { - DocumentI18nQuery::create() - ->filterByPrimaryKeys($this->documentI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->documentI18nsScheduledForDeletion = null; - } - } - - if ($this->collDocumentI18ns !== null) { - foreach ($this->collDocumentI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = DocumentPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . DocumentPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DocumentPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; - } - if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; - } - if ($this->isColumnModified(DocumentPeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`file`'; - } - if ($this->isColumnModified(DocumentPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(DocumentPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `document` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`folder_id`': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case '`content_id`': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case '`file`': - $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aContent !== null) { - if (!$this->aContent->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures()); - } - } - - if ($this->aFolder !== null) { - if (!$this->aFolder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures()); - } - } - - - if (($retval = DocumentPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collDocumentI18ns !== null) { - foreach ($this->collDocumentI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getProductId(); - break; - case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getFolderId(); - break; - case 4: - return $this->getContentId(); - break; - case 5: - return $this->getFile(); - break; - case 6: - return $this->getPosition(); - break; - case 7: - return $this->getCreatedAt(); - break; - case 8: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Document'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Document'][$this->getPrimaryKey()] = true; - $keys = DocumentPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getProductId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getFolderId(), - $keys[4] => $this->getContentId(), - $keys[5] => $this->getFile(), - $keys[6] => $this->getPosition(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collDocumentI18ns) { - $result['DocumentI18ns'] = $this->collDocumentI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = DocumentPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setProductId($value); - break; - case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setFolderId($value); - break; - case 4: - $this->setContentId($value); - break; - case 5: - $this->setFile($value); - break; - case 6: - $this->setPosition($value); - break; - case 7: - $this->setCreatedAt($value); - break; - case 8: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = DocumentPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - - if ($this->isColumnModified(DocumentPeer::ID)) $criteria->add(DocumentPeer::ID, $this->id); - if ($this->isColumnModified(DocumentPeer::PRODUCT_ID)) $criteria->add(DocumentPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(DocumentPeer::CATEGORY_ID)) $criteria->add(DocumentPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(DocumentPeer::FOLDER_ID)) $criteria->add(DocumentPeer::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(DocumentPeer::CONTENT_ID)) $criteria->add(DocumentPeer::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(DocumentPeer::FILE)) $criteria->add(DocumentPeer::FILE, $this->file); - if ($this->isColumnModified(DocumentPeer::POSITION)) $criteria->add(DocumentPeer::POSITION, $this->position); - if ($this->isColumnModified(DocumentPeer::CREATED_AT)) $criteria->add(DocumentPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(DocumentPeer::UPDATED_AT)) $criteria->add(DocumentPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - $criteria->add(DocumentPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Document (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setFile($this->getFile()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getDocumentI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocumentI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Document Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return DocumentPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new DocumentPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Document The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addDocuments($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return Document The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addDocuments($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return Document The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(Content $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Content object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addDocuments($this); - */ - } - - return $this->aContent; - } - - /** - * Declares an association between this object and a Folder object. - * - * @param Folder $v - * @return Document The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(Folder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Folder object, it will not be re-added. - if ($v !== null) { - $v->addDocument($this); - } - - - return $this; - } - - - /** - * Get the associated Folder object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addDocuments($this); - */ - } - - return $this->aFolder; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('DocumentI18n' == $relationName) { - $this->initDocumentI18ns(); - } - } - - /** - * Clears out the collDocumentI18ns 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 Document The current object (for fluent API support) - * @see addDocumentI18ns() - */ - public function clearDocumentI18ns() - { - $this->collDocumentI18ns = null; // important to set this to null since that means it is uninitialized - $this->collDocumentI18nsPartial = null; - - return $this; - } - - /** - * reset is the collDocumentI18ns collection loaded partially - * - * @return void - */ - public function resetPartialDocumentI18ns($v = true) - { - $this->collDocumentI18nsPartial = $v; - } - - /** - * Initializes the collDocumentI18ns collection. - * - * By default this just sets the collDocumentI18ns collection to an empty array (like clearcollDocumentI18ns()); - * 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 initDocumentI18ns($overrideExisting = true) - { - if (null !== $this->collDocumentI18ns && !$overrideExisting) { - return; - } - $this->collDocumentI18ns = new PropelObjectCollection(); - $this->collDocumentI18ns->setModel('DocumentI18n'); - } - - /** - * Gets an array of DocumentI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Document is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|DocumentI18n[] List of DocumentI18n objects - * @throws PropelException - */ - public function getDocumentI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentI18nsPartial && !$this->isNew(); - if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocumentI18ns) { - // return empty collection - $this->initDocumentI18ns(); - } else { - $collDocumentI18ns = DocumentI18nQuery::create(null, $criteria) - ->filterByDocument($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentI18nsPartial && count($collDocumentI18ns)) { - $this->initDocumentI18ns(false); - - foreach($collDocumentI18ns as $obj) { - if (false == $this->collDocumentI18ns->contains($obj)) { - $this->collDocumentI18ns->append($obj); - } - } - - $this->collDocumentI18nsPartial = true; - } - - $collDocumentI18ns->getInternalIterator()->rewind(); - return $collDocumentI18ns; - } - - if($partial && $this->collDocumentI18ns) { - foreach($this->collDocumentI18ns as $obj) { - if($obj->isNew()) { - $collDocumentI18ns[] = $obj; - } - } - } - - $this->collDocumentI18ns = $collDocumentI18ns; - $this->collDocumentI18nsPartial = false; - } - } - - return $this->collDocumentI18ns; - } - - /** - * Sets a collection of DocumentI18n 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 $documentI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Document The current object (for fluent API support) - */ - public function setDocumentI18ns(PropelCollection $documentI18ns, PropelPDO $con = null) - { - $documentI18nsToDelete = $this->getDocumentI18ns(new Criteria(), $con)->diff($documentI18ns); - - $this->documentI18nsScheduledForDeletion = unserialize(serialize($documentI18nsToDelete)); - - foreach ($documentI18nsToDelete as $documentI18nRemoved) { - $documentI18nRemoved->setDocument(null); - } - - $this->collDocumentI18ns = null; - foreach ($documentI18ns as $documentI18n) { - $this->addDocumentI18n($documentI18n); - } - - $this->collDocumentI18ns = $documentI18ns; - $this->collDocumentI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related DocumentI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related DocumentI18n objects. - * @throws PropelException - */ - public function countDocumentI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentI18nsPartial && !$this->isNew(); - if (null === $this->collDocumentI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocumentI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDocumentI18ns()); - } - $query = DocumentI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByDocument($this) - ->count($con); - } - - return count($this->collDocumentI18ns); - } - - /** - * Method called to associate a DocumentI18n object to this object - * through the DocumentI18n foreign key attribute. - * - * @param DocumentI18n $l DocumentI18n - * @return Document The current object (for fluent API support) - */ - public function addDocumentI18n(DocumentI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collDocumentI18ns === null) { - $this->initDocumentI18ns(); - $this->collDocumentI18nsPartial = true; - } - if (!in_array($l, $this->collDocumentI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocumentI18n($l); - } - - return $this; - } - - /** - * @param DocumentI18n $documentI18n The documentI18n object to add. - */ - protected function doAddDocumentI18n($documentI18n) - { - $this->collDocumentI18ns[]= $documentI18n; - $documentI18n->setDocument($this); - } - - /** - * @param DocumentI18n $documentI18n The documentI18n object to remove. - * @return Document The current object (for fluent API support) - */ - public function removeDocumentI18n($documentI18n) - { - if ($this->getDocumentI18ns()->contains($documentI18n)) { - $this->collDocumentI18ns->remove($this->collDocumentI18ns->search($documentI18n)); - if (null === $this->documentI18nsScheduledForDeletion) { - $this->documentI18nsScheduledForDeletion = clone $this->collDocumentI18ns; - $this->documentI18nsScheduledForDeletion->clear(); - } - $this->documentI18nsScheduledForDeletion[]= clone $documentI18n; - $documentI18n->setDocument(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; - $this->content_id = null; - $this->file = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collDocumentI18ns) { - foreach ($this->collDocumentI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collDocumentI18ns instanceof PropelCollection) { - $this->collDocumentI18ns->clearIterator(); - } - $this->collDocumentI18ns = null; - $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(DocumentPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Document The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = DocumentPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Document The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return DocumentI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collDocumentI18ns) { - foreach ($this->collDocumentI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new DocumentI18n(); - $translation->setLocale($locale); - } else { - $translation = DocumentI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addDocumentI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Document The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - DocumentI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collDocumentI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collDocumentI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return DocumentI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18n.php b/core/lib/Thelia/Model/om/BaseDocumentI18n.php deleted file mode 100755 index 19b93544b..000000000 --- a/core/lib/Thelia/Model/om/BaseDocumentI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseDocumentI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = DocumentI18nPeer::ID; - } - - if ($this->aDocument !== null && $this->aDocument->getId() !== $v) { - $this->aDocument = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = DocumentI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = DocumentI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = DocumentI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = DocumentI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return DocumentI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = DocumentI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = DocumentI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating DocumentI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aDocument !== null && $this->id !== $this->aDocument->getId()) { - $this->aDocument = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::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 = DocumentI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aDocument = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = DocumentI18nQuery::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(DocumentI18nPeer::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); - DocumentI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aDocument !== null) { - if ($this->aDocument->isModified() || $this->aDocument->isNew()) { - $affectedRows += $this->aDocument->save($con); - } - $this->setDocument($this->aDocument); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(DocumentI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(DocumentI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(DocumentI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(DocumentI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(DocumentI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(DocumentI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `document_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aDocument !== null) { - if (!$this->aDocument->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aDocument->getValidationFailures()); - } - } - - - if (($retval = DocumentI18nPeer::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 = DocumentI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['DocumentI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['DocumentI18n'][serialize($this->getPrimaryKey())] = true; - $keys = DocumentI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aDocument) { - $result['Document'] = $this->aDocument->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = DocumentI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = DocumentI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(DocumentI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(DocumentI18nPeer::ID)) $criteria->add(DocumentI18nPeer::ID, $this->id); - if ($this->isColumnModified(DocumentI18nPeer::LOCALE)) $criteria->add(DocumentI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(DocumentI18nPeer::TITLE)) $criteria->add(DocumentI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(DocumentI18nPeer::DESCRIPTION)) $criteria->add(DocumentI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(DocumentI18nPeer::CHAPO)) $criteria->add(DocumentI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(DocumentI18nPeer::POSTSCRIPTUM)) $criteria->add(DocumentI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(DocumentI18nPeer::DATABASE_NAME); - $criteria->add(DocumentI18nPeer::ID, $this->id); - $criteria->add(DocumentI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 DocumentI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 DocumentI18n 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 DocumentI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new DocumentI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Document object. - * - * @param Document $v - * @return DocumentI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setDocument(Document $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aDocument = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Document object, it will not be re-added. - if ($v !== null) { - $v->addDocumentI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Document object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Document The associated Document object. - * @throws PropelException - */ - public function getDocument(PropelPDO $con = null, $doQuery = true) - { - if ($this->aDocument === null && ($this->id !== null) && $doQuery) { - $this->aDocument = DocumentQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aDocument->addDocumentI18ns($this); - */ - } - - return $this->aDocument; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aDocument instanceof Persistent) { - $this->aDocument->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aDocument = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(DocumentI18nPeer::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/BaseDocumentI18nPeer.php b/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php deleted file mode 100755 index e59601028..000000000 --- a/core/lib/Thelia/Model/om/BaseDocumentI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (DocumentI18nPeer::ID, DocumentI18nPeer::LOCALE, DocumentI18nPeer::TITLE, DocumentI18nPeer::DESCRIPTION, DocumentI18nPeer::CHAPO, DocumentI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. DocumentI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (DocumentI18nPeer::ID => 0, DocumentI18nPeer::LOCALE => 1, DocumentI18nPeer::TITLE => 2, DocumentI18nPeer::DESCRIPTION => 3, DocumentI18nPeer::CHAPO => 4, DocumentI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = DocumentI18nPeer::getFieldNames($toType); - $key = isset(DocumentI18nPeer::$fieldKeys[$fromType][$name]) ? DocumentI18nPeer::$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(DocumentI18nPeer::$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, DocumentI18nPeer::$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 DocumentI18nPeer::$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. DocumentI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(DocumentI18nPeer::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(DocumentI18nPeer::ID); - $criteria->addSelectColumn(DocumentI18nPeer::LOCALE); - $criteria->addSelectColumn(DocumentI18nPeer::TITLE); - $criteria->addSelectColumn(DocumentI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(DocumentI18nPeer::CHAPO); - $criteria->addSelectColumn(DocumentI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(DocumentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(DocumentI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::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 DocumentI18n - * @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 = DocumentI18nPeer::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 DocumentI18nPeer::populateObjects(DocumentI18nPeer::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 directly (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(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - DocumentI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(DocumentI18nPeer::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 DocumentI18n $obj A DocumentI18n 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->getLocale())); - } // if key === null - DocumentI18nPeer::$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 DocumentI18n 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 DocumentI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 DocumentI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(DocumentI18nPeer::$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 DocumentI18n 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(DocumentI18nPeer::$instances[$key])) { - return DocumentI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (DocumentI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - DocumentI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to document_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = DocumentI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = DocumentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = DocumentI18nPeer::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; - DocumentI18nPeer::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 (DocumentI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = DocumentI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = DocumentI18nPeer::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 + DocumentI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = DocumentI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - DocumentI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Document table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinDocument(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentI18nPeer::ID, DocumentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of DocumentI18n objects pre-filled with their Document objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of DocumentI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinDocument(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentI18nPeer::DATABASE_NAME); - } - - DocumentI18nPeer::addSelectColumns($criteria); - $startcol = DocumentI18nPeer::NUM_HYDRATE_COLUMNS; - DocumentPeer::addSelectColumns($criteria); - - $criteria->addJoin(DocumentI18nPeer::ID, DocumentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DocumentI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = DocumentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = DocumentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - DocumentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (DocumentI18n) to $obj2 (Document) - $obj2->addDocumentI18n($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(DocumentI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentI18nPeer::ID, DocumentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of DocumentI18n 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 DocumentI18n 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(DocumentI18nPeer::DATABASE_NAME); - } - - DocumentI18nPeer::addSelectColumns($criteria); - $startcol2 = DocumentI18nPeer::NUM_HYDRATE_COLUMNS; - - DocumentPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + DocumentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentI18nPeer::ID, DocumentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Document rows - - $key2 = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = DocumentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = DocumentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - DocumentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (DocumentI18n) to the collection in $obj2 (Document) - $obj2->addDocumentI18n($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(DocumentI18nPeer::DATABASE_NAME)->getTable(DocumentI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseDocumentI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseDocumentI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new DocumentI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return DocumentI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a DocumentI18n or Criteria object. - * - * @param mixed $values Criteria or DocumentI18n 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(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from DocumentI18n object - } - - - // Set the correct dbName - $criteria->setDbName(DocumentI18nPeer::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 DocumentI18n or Criteria object. - * - * @param mixed $values Criteria or DocumentI18n 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(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(DocumentI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(DocumentI18nPeer::ID); - $value = $criteria->remove(DocumentI18nPeer::ID); - if ($value) { - $selectCriteria->add(DocumentI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(DocumentI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(DocumentI18nPeer::LOCALE); - $value = $criteria->remove(DocumentI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(DocumentI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(DocumentI18nPeer::TABLE_NAME); - } - - } else { // $values is DocumentI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(DocumentI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the document_i18n 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(DocumentI18nPeer::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(DocumentI18nPeer::TABLE_NAME, $con, DocumentI18nPeer::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). - DocumentI18nPeer::clearInstancePool(); - DocumentI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a DocumentI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or DocumentI18n 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(DocumentI18nPeer::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. - DocumentI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof DocumentI18n) { // it's a model object - // invalidate the cache for this single object - DocumentI18nPeer::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(DocumentI18nPeer::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(DocumentI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(DocumentI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - DocumentI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(DocumentI18nPeer::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); - DocumentI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given DocumentI18n 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 DocumentI18n $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(DocumentI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(DocumentI18nPeer::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(DocumentI18nPeer::DATABASE_NAME, DocumentI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return DocumentI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = DocumentI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(DocumentI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(DocumentI18nPeer::DATABASE_NAME); - $criteria->add(DocumentI18nPeer::ID, $id); - $criteria->add(DocumentI18nPeer::LOCALE, $locale); - $v = DocumentI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseDocumentI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseDocumentI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php b/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php deleted file mode 100755 index 307471f35..000000000 --- a/core/lib/Thelia/Model/om/BaseDocumentI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return DocumentI18n|DocumentI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = DocumentI18nPeer::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(DocumentI18nPeer::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 DocumentI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `document_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 DocumentI18n(); - $obj->hydrate($row); - DocumentI18nPeer::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 DocumentI18n|DocumentI18n[]|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|DocumentI18n[]|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 DocumentI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(DocumentI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(DocumentI18nPeer::LOCALE, $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 DocumentI18nQuery 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(DocumentI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(DocumentI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByDocument() - * - * @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 DocumentI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(DocumentI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(DocumentI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 DocumentI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Document object - * - * @param Document|PropelObjectCollection $document The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(DocumentI18nPeer::ID, $document->getId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentI18nPeer::ID, $document->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Exclude object from result - * - * @param DocumentI18n $documentI18n Object to remove from the list of results - * - * @return DocumentI18nQuery The current query, for fluid interface - */ - public function prune($documentI18n = null) - { - if ($documentI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(DocumentI18nPeer::ID), $documentI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(DocumentI18nPeer::LOCALE), $documentI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseDocumentPeer.php b/core/lib/Thelia/Model/om/BaseDocumentPeer.php deleted file mode 100755 index 5025124d7..000000000 --- a/core/lib/Thelia/Model/om/BaseDocumentPeer.php +++ /dev/null @@ -1,2200 +0,0 @@ - array ('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (DocumentPeer::ID, DocumentPeer::PRODUCT_ID, DocumentPeer::CATEGORY_ID, DocumentPeer::FOLDER_ID, DocumentPeer::CONTENT_ID, DocumentPeer::FILE, DocumentPeer::POSITION, DocumentPeer::CREATED_AT, DocumentPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. DocumentPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - BasePeer::TYPE_COLNAME => array (DocumentPeer::ID => 0, DocumentPeer::PRODUCT_ID => 1, DocumentPeer::CATEGORY_ID => 2, DocumentPeer::FOLDER_ID => 3, DocumentPeer::CONTENT_ID => 4, DocumentPeer::FILE => 5, DocumentPeer::POSITION => 6, DocumentPeer::CREATED_AT => 7, DocumentPeer::UPDATED_AT => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = DocumentPeer::getFieldNames($toType); - $key = isset(DocumentPeer::$fieldKeys[$fromType][$name]) ? DocumentPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(DocumentPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, DocumentPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return DocumentPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. DocumentPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(DocumentPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(DocumentPeer::ID); - $criteria->addSelectColumn(DocumentPeer::PRODUCT_ID); - $criteria->addSelectColumn(DocumentPeer::CATEGORY_ID); - $criteria->addSelectColumn(DocumentPeer::FOLDER_ID); - $criteria->addSelectColumn(DocumentPeer::CONTENT_ID); - $criteria->addSelectColumn(DocumentPeer::FILE); - $criteria->addSelectColumn(DocumentPeer::POSITION); - $criteria->addSelectColumn(DocumentPeer::CREATED_AT); - $criteria->addSelectColumn(DocumentPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.folder_id'); - $criteria->addSelectColumn($alias . '.content_id'); - $criteria->addSelectColumn($alias . '.file'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(DocumentPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Document - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = DocumentPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return DocumentPeer::populateObjects(DocumentPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - DocumentPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Document $obj A Document object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - DocumentPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Document object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Document) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Document object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(DocumentPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Document Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(DocumentPeer::$instances[$key])) { - return DocumentPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (DocumentPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - DocumentPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to document - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in DocumentI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = DocumentPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = DocumentPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - DocumentPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Document object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = DocumentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = DocumentPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + DocumentPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = DocumentPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - DocumentPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Document objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Document) to $obj2 (Product) - $obj2->addDocument($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Document) to $obj2 (Category) - $obj2->addDocument($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with their Content objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Document) to $obj2 (Content) - $obj2->addDocument($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with their Folder objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol = DocumentPeer::NUM_HYDRATE_COLUMNS; - FolderPeer::addSelectColumns($criteria); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FolderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FolderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FolderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Document) to $obj2 (Folder) - $obj2->addDocument($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Document objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Document) to the collection in $obj2 (Product) - $obj2->addDocument($obj1); - } // if joined row not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Document) to the collection in $obj3 (Category) - $obj3->addDocument($obj1); - } // if joined row not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (Document) to the collection in $obj4 (Content) - $obj4->addDocument($obj1); - } // if joined row not null - - // Add objects for joined Folder rows - - $key5 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = FolderPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = FolderPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - FolderPeer::addInstanceToPool($obj5, $key5); - } // if obj5 loaded - - // Add the $obj1 (Document) to the collection in $obj5 (Folder) - $obj5->addDocument($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - DocumentPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Document objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Document) to the collection in $obj2 (Category) - $obj2->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Document) to the collection in $obj3 (Content) - $obj3->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Document) to the collection in $obj4 (Folder) - $obj4->addDocument($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Document) to the collection in $obj2 (Product) - $obj2->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Document) to the collection in $obj3 (Content) - $obj3->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Document) to the collection in $obj4 (Folder) - $obj4->addDocument($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with all related objects except Content. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Document) to the collection in $obj2 (Product) - $obj2->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Document) to the collection in $obj3 (Category) - $obj3->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Document) to the collection in $obj4 (Folder) - $obj4->addDocument($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Document objects pre-filled with all related objects except Folder. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Document objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - } - - DocumentPeer::addSelectColumns($criteria); - $startcol2 = DocumentPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(DocumentPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(DocumentPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = DocumentPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = DocumentPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = DocumentPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - DocumentPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Document) to the collection in $obj2 (Product) - $obj2->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Document) to the collection in $obj3 (Category) - $obj3->addDocument($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Document) to the collection in $obj4 (Content) - $obj4->addDocument($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(DocumentPeer::DATABASE_NAME)->getTable(DocumentPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseDocumentPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseDocumentPeer::TABLE_NAME)) { - $dbMap->addTableObject(new DocumentTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return DocumentPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Document or Criteria object. - * - * @param mixed $values Criteria or Document object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Document object - } - - if ($criteria->containsKey(DocumentPeer::ID) && $criteria->keyContainsValue(DocumentPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.DocumentPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Document or Criteria object. - * - * @param mixed $values Criteria or Document object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(DocumentPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(DocumentPeer::ID); - $value = $criteria->remove(DocumentPeer::ID); - if ($value) { - $selectCriteria->add(DocumentPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(DocumentPeer::TABLE_NAME); - } - - } else { // $values is Document object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the document table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(DocumentPeer::TABLE_NAME, $con, DocumentPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - DocumentPeer::clearInstancePool(); - DocumentPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Document or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Document object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - DocumentPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Document) { // it's a model object - // invalidate the cache for this single object - DocumentPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - $criteria->add(DocumentPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - DocumentPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(DocumentPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - DocumentPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Document object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Document $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(DocumentPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(DocumentPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(DocumentPeer::DATABASE_NAME, DocumentPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Document - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = DocumentPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - $criteria->add(DocumentPeer::ID, $pk); - - $v = DocumentPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Document[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(DocumentPeer::DATABASE_NAME); - $criteria->add(DocumentPeer::ID, $pks, Criteria::IN); - $objs = DocumentPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseDocumentPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseDocumentPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseDocumentQuery.php b/core/lib/Thelia/Model/om/BaseDocumentQuery.php deleted file mode 100755 index 5e5f95712..000000000 --- a/core/lib/Thelia/Model/om/BaseDocumentQuery.php +++ /dev/null @@ -1,1177 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Document|Document[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = DocumentPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(DocumentPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Document A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Document A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `product_id`, `category_id`, `folder_id`, `content_id`, `file`, `position`, `created_at`, `updated_at` FROM `document` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Document(); - $obj->hydrate($row); - DocumentPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Document|Document[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Document[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(DocumentPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(DocumentPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(DocumentPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(DocumentPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 - * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 - * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the file column - * - * Example usage: - * - * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' - * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' - * - * - * @param string $file The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByFile($file = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($file)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $file)) { - $file = str_replace('*', '%', $file); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(DocumentPeer::FILE, $file, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(DocumentPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(DocumentPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(DocumentPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Content object - * - * @param Content|PropelObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof Content) { - return $this - ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Filter the query by a related Folder object - * - * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof Folder) { - return $this - ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(DocumentPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related DocumentI18n object - * - * @param DocumentI18n|PropelObjectCollection $documentI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return DocumentQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocumentI18n($documentI18n, $comparison = null) - { - if ($documentI18n instanceof DocumentI18n) { - return $this - ->addUsingAlias(DocumentPeer::ID, $documentI18n->getId(), $comparison); - } elseif ($documentI18n instanceof PropelObjectCollection) { - return $this - ->useDocumentI18nQuery() - ->filterByPrimaryKeys($documentI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocumentI18n() only accepts arguments of type DocumentI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the DocumentI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinDocumentI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('DocumentI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'DocumentI18n'); - } - - return $this; - } - - /** - * Use the DocumentI18n relation DocumentI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentI18nQuery A secondary query class using the current class as primary query - */ - public function useDocumentI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinDocumentI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', '\Thelia\Model\DocumentI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Document $document Object to remove from the list of results - * - * @return DocumentQuery The current query, for fluid interface - */ - public function prune($document = null) - { - if ($document) { - $this->addUsingAlias(DocumentPeer::ID, $document->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return DocumentQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(DocumentPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return DocumentQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(DocumentPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return DocumentQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(DocumentPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return DocumentQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(DocumentPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return DocumentQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(DocumentPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return DocumentQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(DocumentPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'DocumentI18n'; - - return $this - ->joinDocumentI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return DocumentQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('DocumentI18n'); - $this->with['DocumentI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return DocumentI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'DocumentI18n', 'Thelia\Model\DocumentI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeature.php b/core/lib/Thelia/Model/om/BaseFeature.php deleted file mode 100755 index 6aeaa9410..000000000 --- a/core/lib/Thelia/Model/om/BaseFeature.php +++ /dev/null @@ -1,2782 +0,0 @@ -visible = 0; - } - - /** - * Initializes internal state of BaseFeature object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [visible] column value. - * - * @return int - */ - public function getVisible() - { - return $this->visible; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Feature The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeaturePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [visible] column. - * - * @param int $v new value - * @return Feature The current object (for fluent API support) - */ - public function setVisible($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->visible !== $v) { - $this->visible = $v; - $this->modifiedColumns[] = FeaturePeer::VISIBLE; - } - - - return $this; - } // setVisible() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Feature The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = FeaturePeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Feature The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = FeaturePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Feature The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = FeaturePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->visible !== 0) { - return false; - } - - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->visible = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->position = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = FeaturePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Feature object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = FeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collFeatureAvs = null; - - $this->collFeatureProds = null; - - $this->collFeatureCategorys = null; - - $this->collFeatureI18ns = null; - - $this->collCategorys = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(FeaturePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FeaturePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeaturePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - FeaturePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->categorysScheduledForDeletion = null; - } - - foreach ($this->getCategorys() as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } - - if ($this->featureAvsScheduledForDeletion !== null) { - if (!$this->featureAvsScheduledForDeletion->isEmpty()) { - FeatureAvQuery::create() - ->filterByPrimaryKeys($this->featureAvsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureAvsScheduledForDeletion = null; - } - } - - if ($this->collFeatureAvs !== null) { - foreach ($this->collFeatureAvs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureProdsScheduledForDeletion !== null) { - if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - FeatureProdQuery::create() - ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureProdsScheduledForDeletion = null; - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureCategorysScheduledForDeletion !== null) { - if (!$this->featureCategorysScheduledForDeletion->isEmpty()) { - FeatureCategoryQuery::create() - ->filterByPrimaryKeys($this->featureCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureCategorysScheduledForDeletion = null; - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureI18nsScheduledForDeletion !== null) { - if (!$this->featureI18nsScheduledForDeletion->isEmpty()) { - FeatureI18nQuery::create() - ->filterByPrimaryKeys($this->featureI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureI18nsScheduledForDeletion = null; - } - } - - if ($this->collFeatureI18ns !== null) { - foreach ($this->collFeatureI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = FeaturePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeaturePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeaturePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeaturePeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; - } - if ($this->isColumnModified(FeaturePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(FeaturePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `feature` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`visible`': - $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = FeaturePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collFeatureAvs !== null) { - foreach ($this->collFeatureAvs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureCategorys !== null) { - foreach ($this->collFeatureCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureI18ns !== null) { - foreach ($this->collFeatureI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getVisible(); - break; - case 2: - return $this->getPosition(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Feature'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Feature'][$this->getPrimaryKey()] = true; - $keys = FeaturePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getVisible(), - $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collFeatureAvs) { - $result['FeatureAvs'] = $this->collFeatureAvs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureProds) { - $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureCategorys) { - $result['FeatureCategorys'] = $this->collFeatureCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureI18ns) { - $result['FeatureI18ns'] = $this->collFeatureI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setVisible($value); - break; - case 2: - $this->setPosition($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = FeaturePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - - if ($this->isColumnModified(FeaturePeer::ID)) $criteria->add(FeaturePeer::ID, $this->id); - if ($this->isColumnModified(FeaturePeer::VISIBLE)) $criteria->add(FeaturePeer::VISIBLE, $this->visible); - if ($this->isColumnModified(FeaturePeer::POSITION)) $criteria->add(FeaturePeer::POSITION, $this->position); - if ($this->isColumnModified(FeaturePeer::CREATED_AT)) $criteria->add(FeaturePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeaturePeer::UPDATED_AT)) $criteria->add(FeaturePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - $criteria->add(FeaturePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Feature (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setVisible($this->getVisible()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getFeatureAvs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureAv($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureProds() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureProd($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Feature Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return FeaturePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeaturePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('FeatureAv' == $relationName) { - $this->initFeatureAvs(); - } - if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); - } - if ('FeatureCategory' == $relationName) { - $this->initFeatureCategorys(); - } - if ('FeatureI18n' == $relationName) { - $this->initFeatureI18ns(); - } - } - - /** - * Clears out the collFeatureAvs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Feature The current object (for fluent API support) - * @see addFeatureAvs() - */ - public function clearFeatureAvs() - { - $this->collFeatureAvs = null; // important to set this to null since that means it is uninitialized - $this->collFeatureAvsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureAvs collection loaded partially - * - * @return void - */ - public function resetPartialFeatureAvs($v = true) - { - $this->collFeatureAvsPartial = $v; - } - - /** - * Initializes the collFeatureAvs collection. - * - * By default this just sets the collFeatureAvs collection to an empty array (like clearcollFeatureAvs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureAvs($overrideExisting = true) - { - if (null !== $this->collFeatureAvs && !$overrideExisting) { - return; - } - $this->collFeatureAvs = new PropelObjectCollection(); - $this->collFeatureAvs->setModel('FeatureAv'); - } - - /** - * Gets an array of FeatureAv objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureAv[] List of FeatureAv objects - * @throws PropelException - */ - public function getFeatureAvs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureAvsPartial && !$this->isNew(); - if (null === $this->collFeatureAvs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureAvs) { - // return empty collection - $this->initFeatureAvs(); - } else { - $collFeatureAvs = FeatureAvQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureAvsPartial && count($collFeatureAvs)) { - $this->initFeatureAvs(false); - - foreach($collFeatureAvs as $obj) { - if (false == $this->collFeatureAvs->contains($obj)) { - $this->collFeatureAvs->append($obj); - } - } - - $this->collFeatureAvsPartial = true; - } - - $collFeatureAvs->getInternalIterator()->rewind(); - return $collFeatureAvs; - } - - if($partial && $this->collFeatureAvs) { - foreach($this->collFeatureAvs as $obj) { - if($obj->isNew()) { - $collFeatureAvs[] = $obj; - } - } - } - - $this->collFeatureAvs = $collFeatureAvs; - $this->collFeatureAvsPartial = false; - } - } - - return $this->collFeatureAvs; - } - - /** - * Sets a collection of FeatureAv objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureAvs A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Feature The current object (for fluent API support) - */ - public function setFeatureAvs(PropelCollection $featureAvs, PropelPDO $con = null) - { - $featureAvsToDelete = $this->getFeatureAvs(new Criteria(), $con)->diff($featureAvs); - - $this->featureAvsScheduledForDeletion = unserialize(serialize($featureAvsToDelete)); - - foreach ($featureAvsToDelete as $featureAvRemoved) { - $featureAvRemoved->setFeature(null); - } - - $this->collFeatureAvs = null; - foreach ($featureAvs as $featureAv) { - $this->addFeatureAv($featureAv); - } - - $this->collFeatureAvs = $featureAvs; - $this->collFeatureAvsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureAv objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureAv objects. - * @throws PropelException - */ - public function countFeatureAvs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureAvsPartial && !$this->isNew(); - if (null === $this->collFeatureAvs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureAvs) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureAvs()); - } - $query = FeatureAvQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - - return count($this->collFeatureAvs); - } - - /** - * Method called to associate a FeatureAv object to this object - * through the FeatureAv foreign key attribute. - * - * @param FeatureAv $l FeatureAv - * @return Feature The current object (for fluent API support) - */ - public function addFeatureAv(FeatureAv $l) - { - if ($this->collFeatureAvs === null) { - $this->initFeatureAvs(); - $this->collFeatureAvsPartial = true; - } - if (!in_array($l, $this->collFeatureAvs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureAv($l); - } - - return $this; - } - - /** - * @param FeatureAv $featureAv The featureAv object to add. - */ - protected function doAddFeatureAv($featureAv) - { - $this->collFeatureAvs[]= $featureAv; - $featureAv->setFeature($this); - } - - /** - * @param FeatureAv $featureAv The featureAv object to remove. - * @return Feature The current object (for fluent API support) - */ - public function removeFeatureAv($featureAv) - { - if ($this->getFeatureAvs()->contains($featureAv)) { - $this->collFeatureAvs->remove($this->collFeatureAvs->search($featureAv)); - if (null === $this->featureAvsScheduledForDeletion) { - $this->featureAvsScheduledForDeletion = clone $this->collFeatureAvs; - $this->featureAvsScheduledForDeletion->clear(); - } - $this->featureAvsScheduledForDeletion[]= clone $featureAv; - $featureAv->setFeature(null); - } - - return $this; - } - - /** - * Clears out the collFeatureProds collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Feature The current object (for fluent API support) - * @see addFeatureProds() - */ - public function clearFeatureProds() - { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureProds collection loaded partially - * - * @return void - */ - public function resetPartialFeatureProds($v = true) - { - $this->collFeatureProdsPartial = $v; - } - - /** - * Initializes the collFeatureProds collection. - * - * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureProds($overrideExisting = true) - { - if (null !== $this->collFeatureProds && !$overrideExisting) { - return; - } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); - } - - /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - * @throws PropelException - */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - // return empty collection - $this->initFeatureProds(); - } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); - - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); - } - } - - $this->collFeatureProdsPartial = true; - } - - $collFeatureProds->getInternalIterator()->rewind(); - return $collFeatureProds; - } - - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { - $collFeatureProds[] = $obj; - } - } - } - - $this->collFeatureProds = $collFeatureProds; - $this->collFeatureProdsPartial = false; - } - } - - return $this->collFeatureProds; - } - - /** - * Sets a collection of FeatureProd objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureProds A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Feature The current object (for fluent API support) - */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) - { - $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); - - foreach ($featureProdsToDelete as $featureProdRemoved) { - $featureProdRemoved->setFeature(null); - } - - $this->collFeatureProds = null; - foreach ($featureProds as $featureProd) { - $this->addFeatureProd($featureProd); - } - - $this->collFeatureProds = $featureProds; - $this->collFeatureProdsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureProd objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureProd objects. - * @throws PropelException - */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - - return count($this->collFeatureProds); - } - - /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. - * - * @param FeatureProd $l FeatureProd - * @return Feature The current object (for fluent API support) - */ - public function addFeatureProd(FeatureProd $l) - { - if ($this->collFeatureProds === null) { - $this->initFeatureProds(); - $this->collFeatureProdsPartial = true; - } - if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureProd($l); - } - - return $this; - } - - /** - * @param FeatureProd $featureProd The featureProd object to add. - */ - protected function doAddFeatureProd($featureProd) - { - $this->collFeatureProds[]= $featureProd; - $featureProd->setFeature($this); - } - - /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return Feature The current object (for fluent API support) - */ - public function removeFeatureProd($featureProd) - { - if ($this->getFeatureProds()->contains($featureProd)) { - $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); - if (null === $this->featureProdsScheduledForDeletion) { - $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; - $this->featureProdsScheduledForDeletion->clear(); - } - $this->featureProdsScheduledForDeletion[]= clone $featureProd; - $featureProd->setFeature(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Feature is new, it will return - * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Feature. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Feature is new, it will return - * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Feature. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - /** - * Clears out the collFeatureCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Feature The current object (for fluent API support) - * @see addFeatureCategorys() - */ - public function clearFeatureCategorys() - { - $this->collFeatureCategorys = null; // important to set this to null since that means it is uninitialized - $this->collFeatureCategorysPartial = null; - - return $this; - } - - /** - * reset is the collFeatureCategorys collection loaded partially - * - * @return void - */ - public function resetPartialFeatureCategorys($v = true) - { - $this->collFeatureCategorysPartial = $v; - } - - /** - * Initializes the collFeatureCategorys collection. - * - * By default this just sets the collFeatureCategorys collection to an empty array (like clearcollFeatureCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureCategorys($overrideExisting = true) - { - if (null !== $this->collFeatureCategorys && !$overrideExisting) { - return; - } - $this->collFeatureCategorys = new PropelObjectCollection(); - $this->collFeatureCategorys->setModel('FeatureCategory'); - } - - /** - * Gets an array of FeatureCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - * @throws PropelException - */ - public function getFeatureCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { - // return empty collection - $this->initFeatureCategorys(); - } else { - $collFeatureCategorys = FeatureCategoryQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureCategorysPartial && count($collFeatureCategorys)) { - $this->initFeatureCategorys(false); - - foreach($collFeatureCategorys as $obj) { - if (false == $this->collFeatureCategorys->contains($obj)) { - $this->collFeatureCategorys->append($obj); - } - } - - $this->collFeatureCategorysPartial = true; - } - - $collFeatureCategorys->getInternalIterator()->rewind(); - return $collFeatureCategorys; - } - - if($partial && $this->collFeatureCategorys) { - foreach($this->collFeatureCategorys as $obj) { - if($obj->isNew()) { - $collFeatureCategorys[] = $obj; - } - } - } - - $this->collFeatureCategorys = $collFeatureCategorys; - $this->collFeatureCategorysPartial = false; - } - } - - return $this->collFeatureCategorys; - } - - /** - * Sets a collection of FeatureCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Feature The current object (for fluent API support) - */ - public function setFeatureCategorys(PropelCollection $featureCategorys, PropelPDO $con = null) - { - $featureCategorysToDelete = $this->getFeatureCategorys(new Criteria(), $con)->diff($featureCategorys); - - $this->featureCategorysScheduledForDeletion = unserialize(serialize($featureCategorysToDelete)); - - foreach ($featureCategorysToDelete as $featureCategoryRemoved) { - $featureCategoryRemoved->setFeature(null); - } - - $this->collFeatureCategorys = null; - foreach ($featureCategorys as $featureCategory) { - $this->addFeatureCategory($featureCategory); - } - - $this->collFeatureCategorys = $featureCategorys; - $this->collFeatureCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureCategory objects. - * @throws PropelException - */ - public function countFeatureCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureCategorysPartial && !$this->isNew(); - if (null === $this->collFeatureCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureCategorys()); - } - $query = FeatureCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - - return count($this->collFeatureCategorys); - } - - /** - * Method called to associate a FeatureCategory object to this object - * through the FeatureCategory foreign key attribute. - * - * @param FeatureCategory $l FeatureCategory - * @return Feature The current object (for fluent API support) - */ - public function addFeatureCategory(FeatureCategory $l) - { - if ($this->collFeatureCategorys === null) { - $this->initFeatureCategorys(); - $this->collFeatureCategorysPartial = true; - } - if (!in_array($l, $this->collFeatureCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureCategory($l); - } - - return $this; - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to add. - */ - protected function doAddFeatureCategory($featureCategory) - { - $this->collFeatureCategorys[]= $featureCategory; - $featureCategory->setFeature($this); - } - - /** - * @param FeatureCategory $featureCategory The featureCategory object to remove. - * @return Feature The current object (for fluent API support) - */ - public function removeFeatureCategory($featureCategory) - { - if ($this->getFeatureCategorys()->contains($featureCategory)) { - $this->collFeatureCategorys->remove($this->collFeatureCategorys->search($featureCategory)); - if (null === $this->featureCategorysScheduledForDeletion) { - $this->featureCategorysScheduledForDeletion = clone $this->collFeatureCategorys; - $this->featureCategorysScheduledForDeletion->clear(); - } - $this->featureCategorysScheduledForDeletion[]= clone $featureCategory; - $featureCategory->setFeature(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Feature is new, it will return - * an empty collection; or if this Feature has previously - * been saved, it will retrieve related FeatureCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Feature. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureCategory[] List of FeatureCategory objects - */ - public function getFeatureCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getFeatureCategorys($query, $con); - } - - /** - * Clears out the collFeatureI18ns 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 Feature The current object (for fluent API support) - * @see addFeatureI18ns() - */ - public function clearFeatureI18ns() - { - $this->collFeatureI18ns = null; // important to set this to null since that means it is uninitialized - $this->collFeatureI18nsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureI18ns collection loaded partially - * - * @return void - */ - public function resetPartialFeatureI18ns($v = true) - { - $this->collFeatureI18nsPartial = $v; - } - - /** - * Initializes the collFeatureI18ns collection. - * - * By default this just sets the collFeatureI18ns collection to an empty array (like clearcollFeatureI18ns()); - * 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 initFeatureI18ns($overrideExisting = true) - { - if (null !== $this->collFeatureI18ns && !$overrideExisting) { - return; - } - $this->collFeatureI18ns = new PropelObjectCollection(); - $this->collFeatureI18ns->setModel('FeatureI18n'); - } - - /** - * Gets an array of FeatureI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureI18n[] List of FeatureI18n objects - * @throws PropelException - */ - public function getFeatureI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureI18nsPartial && !$this->isNew(); - if (null === $this->collFeatureI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureI18ns) { - // return empty collection - $this->initFeatureI18ns(); - } else { - $collFeatureI18ns = FeatureI18nQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureI18nsPartial && count($collFeatureI18ns)) { - $this->initFeatureI18ns(false); - - foreach($collFeatureI18ns as $obj) { - if (false == $this->collFeatureI18ns->contains($obj)) { - $this->collFeatureI18ns->append($obj); - } - } - - $this->collFeatureI18nsPartial = true; - } - - $collFeatureI18ns->getInternalIterator()->rewind(); - return $collFeatureI18ns; - } - - if($partial && $this->collFeatureI18ns) { - foreach($this->collFeatureI18ns as $obj) { - if($obj->isNew()) { - $collFeatureI18ns[] = $obj; - } - } - } - - $this->collFeatureI18ns = $collFeatureI18ns; - $this->collFeatureI18nsPartial = false; - } - } - - return $this->collFeatureI18ns; - } - - /** - * Sets a collection of FeatureI18n 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 $featureI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Feature The current object (for fluent API support) - */ - public function setFeatureI18ns(PropelCollection $featureI18ns, PropelPDO $con = null) - { - $featureI18nsToDelete = $this->getFeatureI18ns(new Criteria(), $con)->diff($featureI18ns); - - $this->featureI18nsScheduledForDeletion = unserialize(serialize($featureI18nsToDelete)); - - foreach ($featureI18nsToDelete as $featureI18nRemoved) { - $featureI18nRemoved->setFeature(null); - } - - $this->collFeatureI18ns = null; - foreach ($featureI18ns as $featureI18n) { - $this->addFeatureI18n($featureI18n); - } - - $this->collFeatureI18ns = $featureI18ns; - $this->collFeatureI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureI18n objects. - * @throws PropelException - */ - public function countFeatureI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureI18nsPartial && !$this->isNew(); - if (null === $this->collFeatureI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureI18ns()); - } - $query = FeatureI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - - return count($this->collFeatureI18ns); - } - - /** - * Method called to associate a FeatureI18n object to this object - * through the FeatureI18n foreign key attribute. - * - * @param FeatureI18n $l FeatureI18n - * @return Feature The current object (for fluent API support) - */ - public function addFeatureI18n(FeatureI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collFeatureI18ns === null) { - $this->initFeatureI18ns(); - $this->collFeatureI18nsPartial = true; - } - if (!in_array($l, $this->collFeatureI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureI18n($l); - } - - return $this; - } - - /** - * @param FeatureI18n $featureI18n The featureI18n object to add. - */ - protected function doAddFeatureI18n($featureI18n) - { - $this->collFeatureI18ns[]= $featureI18n; - $featureI18n->setFeature($this); - } - - /** - * @param FeatureI18n $featureI18n The featureI18n object to remove. - * @return Feature The current object (for fluent API support) - */ - public function removeFeatureI18n($featureI18n) - { - if ($this->getFeatureI18ns()->contains($featureI18n)) { - $this->collFeatureI18ns->remove($this->collFeatureI18ns->search($featureI18n)); - if (null === $this->featureI18nsScheduledForDeletion) { - $this->featureI18nsScheduledForDeletion = clone $this->collFeatureI18ns; - $this->featureI18nsScheduledForDeletion->clear(); - } - $this->featureI18nsScheduledForDeletion[]= clone $featureI18n; - $featureI18n->setFeature(null); - } - - return $this; - } - - /** - * Clears out the collCategorys 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 Feature The current object (for fluent API support) - * @see addCategorys() - */ - public function clearCategorys() - { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; - } - - /** - * Initializes the collCategorys collection. - * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); - * 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. - * - * @return void - */ - public function initCategorys() - { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); - } - - /** - * Gets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Feature is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Category[] List of Category objects - */ - public function getCategorys($criteria = null, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - // return empty collection - $this->initCategorys(); - } else { - $collCategorys = CategoryQuery::create(null, $criteria) - ->filterByFeature($this) - ->find($con); - if (null !== $criteria) { - return $collCategorys; - } - $this->collCategorys = $collCategorys; - } - } - - return $this->collCategorys; - } - - /** - * Sets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * 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 $categorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Feature The current object (for fluent API support) - */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) - { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); - - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); - - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { - $this->doAddCategory($category); - } - } - - $this->collCategorys = $categorys; - - return $this; - } - - /** - * Gets the number of Category objects related by a many-to-many relationship - * to the current object by way of the feature_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Category objects - */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - return 0; - } else { - $query = CategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeature($this) - ->count($con); - } - } else { - return count($this->collCategorys); - } - } - - /** - * Associate a Category object to this object - * through the feature_category cross reference table. - * - * @param Category $category The FeatureCategory object to relate - * @return Feature The current object (for fluent API support) - */ - public function addCategory(Category $category) - { - if ($this->collCategorys === null) { - $this->initCategorys(); - } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - - $this->collCategorys[]= $category; - } - - return $this; - } - - /** - * @param Category $category The category object to add. - */ - protected function doAddCategory($category) - { - $featureCategory = new FeatureCategory(); - $featureCategory->setCategory($category); - $this->addFeatureCategory($featureCategory); - } - - /** - * Remove a Category object to this object - * through the feature_category cross reference table. - * - * @param Category $category The FeatureCategory object to relate - * @return Feature The current object (for fluent API support) - */ - public function removeCategory(Category $category) - { - if ($this->getCategorys()->contains($category)) { - $this->collCategorys->remove($this->collCategorys->search($category)); - if (null === $this->categorysScheduledForDeletion) { - $this->categorysScheduledForDeletion = clone $this->collCategorys; - $this->categorysScheduledForDeletion->clear(); - } - $this->categorysScheduledForDeletion[]= $category; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->visible = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collFeatureAvs) { - foreach ($this->collFeatureAvs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureProds) { - foreach ($this->collFeatureProds as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureCategorys) { - foreach ($this->collFeatureCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureI18ns) { - foreach ($this->collFeatureI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collFeatureAvs instanceof PropelCollection) { - $this->collFeatureAvs->clearIterator(); - } - $this->collFeatureAvs = null; - if ($this->collFeatureProds instanceof PropelCollection) { - $this->collFeatureProds->clearIterator(); - } - $this->collFeatureProds = null; - if ($this->collFeatureCategorys instanceof PropelCollection) { - $this->collFeatureCategorys->clearIterator(); - } - $this->collFeatureCategorys = null; - if ($this->collFeatureI18ns instanceof PropelCollection) { - $this->collFeatureI18ns->clearIterator(); - } - $this->collFeatureI18ns = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); - } - $this->collCategorys = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeaturePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Feature The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FeaturePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Feature The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return FeatureI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collFeatureI18ns) { - foreach ($this->collFeatureI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new FeatureI18n(); - $translation->setLocale($locale); - } else { - $translation = FeatureI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addFeatureI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Feature The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - FeatureI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collFeatureI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collFeatureI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return FeatureI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureAv.php b/core/lib/Thelia/Model/om/BaseFeatureAv.php deleted file mode 100755 index adaffcd44..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAv.php +++ /dev/null @@ -1,1988 +0,0 @@ -id; - } - - /** - * Get the [feature_id] column value. - * - * @return int - */ - public function getFeatureId() - { - return $this->feature_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FeatureAv The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeatureAvPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [feature_id] column. - * - * @param int $v new value - * @return FeatureAv The current object (for fluent API support) - */ - public function setFeatureId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->feature_id !== $v) { - $this->feature_id = $v; - $this->modifiedColumns[] = FeatureAvPeer::FEATURE_ID; - } - - if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { - $this->aFeature = null; - } - - - return $this; - } // setFeatureId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureAv The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = FeatureAvPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureAv The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = FeatureAvPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FeatureAv object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { - $this->aFeature = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = FeatureAvPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aFeature = null; - $this->collFeatureProds = null; - - $this->collFeatureAvI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureAvQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(FeatureAvPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - FeatureAvPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeature !== null) { - if ($this->aFeature->isModified() || $this->aFeature->isNew()) { - $affectedRows += $this->aFeature->save($con); - } - $this->setFeature($this->aFeature); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->featureProdsScheduledForDeletion !== null) { - if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - foreach ($this->featureProdsScheduledForDeletion as $featureProd) { - // need to save related object because we set the relation to null - $featureProd->save($con); - } - $this->featureProdsScheduledForDeletion = null; - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureAvI18nsScheduledForDeletion !== null) { - if (!$this->featureAvI18nsScheduledForDeletion->isEmpty()) { - FeatureAvI18nQuery::create() - ->filterByPrimaryKeys($this->featureAvI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureAvI18nsScheduledForDeletion = null; - } - } - - if ($this->collFeatureAvI18ns !== null) { - foreach ($this->collFeatureAvI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = FeatureAvPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureAvPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureAvPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_id`'; - } - if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `feature_av` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`feature_id`': - $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeature !== null) { - if (!$this->aFeature->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures()); - } - } - - - if (($retval = FeatureAvPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureAvI18ns !== null) { - foreach ($this->collFeatureAvI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getFeatureId(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureAv'][$this->getPrimaryKey()] = true; - $keys = FeatureAvPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getFeatureId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aFeature) { - $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collFeatureProds) { - $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureAvI18ns) { - $result['FeatureAvI18ns'] = $this->collFeatureAvI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureAvPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setFeatureId($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = FeatureAvPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - - if ($this->isColumnModified(FeatureAvPeer::ID)) $criteria->add(FeatureAvPeer::ID, $this->id); - if ($this->isColumnModified(FeatureAvPeer::FEATURE_ID)) $criteria->add(FeatureAvPeer::FEATURE_ID, $this->feature_id); - if ($this->isColumnModified(FeatureAvPeer::CREATED_AT)) $criteria->add(FeatureAvPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeatureAvPeer::UPDATED_AT)) $criteria->add(FeatureAvPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - $criteria->add(FeatureAvPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of FeatureAv (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setFeatureId($this->getFeatureId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getFeatureProds() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureProd($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureAvI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureAvI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return FeatureAv Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return FeatureAvPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeatureAvPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Feature object. - * - * @param Feature $v - * @return FeatureAv The current object (for fluent API support) - * @throws PropelException - */ - public function setFeature(Feature $v = null) - { - if ($v === null) { - $this->setFeatureId(NULL); - } else { - $this->setFeatureId($v->getId()); - } - - $this->aFeature = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Feature object, it will not be re-added. - if ($v !== null) { - $v->addFeatureAv($this); - } - - - return $this; - } - - - /** - * Get the associated Feature object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. - * @throws PropelException - */ - public function getFeature(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeature->addFeatureAvs($this); - */ - } - - return $this->aFeature; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); - } - if ('FeatureAvI18n' == $relationName) { - $this->initFeatureAvI18ns(); - } - } - - /** - * Clears out the collFeatureProds collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return FeatureAv The current object (for fluent API support) - * @see addFeatureProds() - */ - public function clearFeatureProds() - { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureProds collection loaded partially - * - * @return void - */ - public function resetPartialFeatureProds($v = true) - { - $this->collFeatureProdsPartial = $v; - } - - /** - * Initializes the collFeatureProds collection. - * - * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureProds($overrideExisting = true) - { - if (null !== $this->collFeatureProds && !$overrideExisting) { - return; - } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); - } - - /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this FeatureAv is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - * @throws PropelException - */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - // return empty collection - $this->initFeatureProds(); - } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) - ->filterByFeatureAv($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); - - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); - } - } - - $this->collFeatureProdsPartial = true; - } - - $collFeatureProds->getInternalIterator()->rewind(); - return $collFeatureProds; - } - - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { - $collFeatureProds[] = $obj; - } - } - } - - $this->collFeatureProds = $collFeatureProds; - $this->collFeatureProdsPartial = false; - } - } - - return $this->collFeatureProds; - } - - /** - * Sets a collection of FeatureProd objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureProds A Propel collection. - * @param PropelPDO $con Optional connection object - * @return FeatureAv The current object (for fluent API support) - */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) - { - $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); - - foreach ($featureProdsToDelete as $featureProdRemoved) { - $featureProdRemoved->setFeatureAv(null); - } - - $this->collFeatureProds = null; - foreach ($featureProds as $featureProd) { - $this->addFeatureProd($featureProd); - } - - $this->collFeatureProds = $featureProds; - $this->collFeatureProdsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureProd objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureProd objects. - * @throws PropelException - */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeatureAv($this) - ->count($con); - } - - return count($this->collFeatureProds); - } - - /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. - * - * @param FeatureProd $l FeatureProd - * @return FeatureAv The current object (for fluent API support) - */ - public function addFeatureProd(FeatureProd $l) - { - if ($this->collFeatureProds === null) { - $this->initFeatureProds(); - $this->collFeatureProdsPartial = true; - } - if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureProd($l); - } - - return $this; - } - - /** - * @param FeatureProd $featureProd The featureProd object to add. - */ - protected function doAddFeatureProd($featureProd) - { - $this->collFeatureProds[]= $featureProd; - $featureProd->setFeatureAv($this); - } - - /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return FeatureAv The current object (for fluent API support) - */ - public function removeFeatureProd($featureProd) - { - if ($this->getFeatureProds()->contains($featureProd)) { - $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); - if (null === $this->featureProdsScheduledForDeletion) { - $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; - $this->featureProdsScheduledForDeletion->clear(); - } - $this->featureProdsScheduledForDeletion[]= $featureProd; - $featureProd->setFeatureAv(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this FeatureAv is new, it will return - * an empty collection; or if this FeatureAv has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in FeatureAv. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this FeatureAv is new, it will return - * an empty collection; or if this FeatureAv has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in FeatureAv. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - /** - * Clears out the collFeatureAvI18ns 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 FeatureAv The current object (for fluent API support) - * @see addFeatureAvI18ns() - */ - public function clearFeatureAvI18ns() - { - $this->collFeatureAvI18ns = null; // important to set this to null since that means it is uninitialized - $this->collFeatureAvI18nsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureAvI18ns collection loaded partially - * - * @return void - */ - public function resetPartialFeatureAvI18ns($v = true) - { - $this->collFeatureAvI18nsPartial = $v; - } - - /** - * Initializes the collFeatureAvI18ns collection. - * - * By default this just sets the collFeatureAvI18ns collection to an empty array (like clearcollFeatureAvI18ns()); - * 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 initFeatureAvI18ns($overrideExisting = true) - { - if (null !== $this->collFeatureAvI18ns && !$overrideExisting) { - return; - } - $this->collFeatureAvI18ns = new PropelObjectCollection(); - $this->collFeatureAvI18ns->setModel('FeatureAvI18n'); - } - - /** - * Gets an array of FeatureAvI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this FeatureAv is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureAvI18n[] List of FeatureAvI18n objects - * @throws PropelException - */ - public function getFeatureAvI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureAvI18nsPartial && !$this->isNew(); - if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureAvI18ns) { - // return empty collection - $this->initFeatureAvI18ns(); - } else { - $collFeatureAvI18ns = FeatureAvI18nQuery::create(null, $criteria) - ->filterByFeatureAv($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureAvI18nsPartial && count($collFeatureAvI18ns)) { - $this->initFeatureAvI18ns(false); - - foreach($collFeatureAvI18ns as $obj) { - if (false == $this->collFeatureAvI18ns->contains($obj)) { - $this->collFeatureAvI18ns->append($obj); - } - } - - $this->collFeatureAvI18nsPartial = true; - } - - $collFeatureAvI18ns->getInternalIterator()->rewind(); - return $collFeatureAvI18ns; - } - - if($partial && $this->collFeatureAvI18ns) { - foreach($this->collFeatureAvI18ns as $obj) { - if($obj->isNew()) { - $collFeatureAvI18ns[] = $obj; - } - } - } - - $this->collFeatureAvI18ns = $collFeatureAvI18ns; - $this->collFeatureAvI18nsPartial = false; - } - } - - return $this->collFeatureAvI18ns; - } - - /** - * Sets a collection of FeatureAvI18n 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 $featureAvI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return FeatureAv The current object (for fluent API support) - */ - public function setFeatureAvI18ns(PropelCollection $featureAvI18ns, PropelPDO $con = null) - { - $featureAvI18nsToDelete = $this->getFeatureAvI18ns(new Criteria(), $con)->diff($featureAvI18ns); - - $this->featureAvI18nsScheduledForDeletion = unserialize(serialize($featureAvI18nsToDelete)); - - foreach ($featureAvI18nsToDelete as $featureAvI18nRemoved) { - $featureAvI18nRemoved->setFeatureAv(null); - } - - $this->collFeatureAvI18ns = null; - foreach ($featureAvI18ns as $featureAvI18n) { - $this->addFeatureAvI18n($featureAvI18n); - } - - $this->collFeatureAvI18ns = $featureAvI18ns; - $this->collFeatureAvI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureAvI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureAvI18n objects. - * @throws PropelException - */ - public function countFeatureAvI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureAvI18nsPartial && !$this->isNew(); - if (null === $this->collFeatureAvI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureAvI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureAvI18ns()); - } - $query = FeatureAvI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFeatureAv($this) - ->count($con); - } - - return count($this->collFeatureAvI18ns); - } - - /** - * Method called to associate a FeatureAvI18n object to this object - * through the FeatureAvI18n foreign key attribute. - * - * @param FeatureAvI18n $l FeatureAvI18n - * @return FeatureAv The current object (for fluent API support) - */ - public function addFeatureAvI18n(FeatureAvI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collFeatureAvI18ns === null) { - $this->initFeatureAvI18ns(); - $this->collFeatureAvI18nsPartial = true; - } - if (!in_array($l, $this->collFeatureAvI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureAvI18n($l); - } - - return $this; - } - - /** - * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to add. - */ - protected function doAddFeatureAvI18n($featureAvI18n) - { - $this->collFeatureAvI18ns[]= $featureAvI18n; - $featureAvI18n->setFeatureAv($this); - } - - /** - * @param FeatureAvI18n $featureAvI18n The featureAvI18n object to remove. - * @return FeatureAv The current object (for fluent API support) - */ - public function removeFeatureAvI18n($featureAvI18n) - { - if ($this->getFeatureAvI18ns()->contains($featureAvI18n)) { - $this->collFeatureAvI18ns->remove($this->collFeatureAvI18ns->search($featureAvI18n)); - if (null === $this->featureAvI18nsScheduledForDeletion) { - $this->featureAvI18nsScheduledForDeletion = clone $this->collFeatureAvI18ns; - $this->featureAvI18nsScheduledForDeletion->clear(); - } - $this->featureAvI18nsScheduledForDeletion[]= clone $featureAvI18n; - $featureAvI18n->setFeatureAv(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->feature_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collFeatureProds) { - foreach ($this->collFeatureProds as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureAvI18ns) { - foreach ($this->collFeatureAvI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aFeature instanceof Persistent) { - $this->aFeature->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collFeatureProds instanceof PropelCollection) { - $this->collFeatureProds->clearIterator(); - } - $this->collFeatureProds = null; - if ($this->collFeatureAvI18ns instanceof PropelCollection) { - $this->collFeatureAvI18ns->clearIterator(); - } - $this->collFeatureAvI18ns = null; - $this->aFeature = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureAvPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return FeatureAv The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FeatureAvPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return FeatureAv The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return FeatureAvI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collFeatureAvI18ns) { - foreach ($this->collFeatureAvI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new FeatureAvI18n(); - $translation->setLocale($locale); - } else { - $translation = FeatureAvI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addFeatureAvI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return FeatureAv The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - FeatureAvI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collFeatureAvI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collFeatureAvI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return FeatureAvI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php deleted file mode 100755 index 5860ad6dc..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseFeatureAvI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::ID; - } - - if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) { - $this->aFeatureAv = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FeatureAvI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = FeatureAvI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = FeatureAvI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FeatureAvI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aFeatureAv !== null && $this->id !== $this->aFeatureAv->getId()) { - $this->aFeatureAv = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::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 = FeatureAvI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aFeatureAv = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureAvI18nQuery::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(FeatureAvI18nPeer::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); - FeatureAvI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeatureAv !== null) { - if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) { - $affectedRows += $this->aFeatureAv->save($con); - } - $this->setFeatureAv($this->aFeatureAv); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureAvI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeatureAvI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(FeatureAvI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(FeatureAvI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(FeatureAvI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(FeatureAvI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `feature_av_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeatureAv !== null) { - if (!$this->aFeatureAv->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeatureAv->getValidationFailures()); - } - } - - - if (($retval = FeatureAvI18nPeer::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 = FeatureAvI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['FeatureAvI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureAvI18n'][serialize($this->getPrimaryKey())] = true; - $keys = FeatureAvI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aFeatureAv) { - $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureAvI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = FeatureAvI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeatureAvI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(FeatureAvI18nPeer::ID)) $criteria->add(FeatureAvI18nPeer::ID, $this->id); - if ($this->isColumnModified(FeatureAvI18nPeer::LOCALE)) $criteria->add(FeatureAvI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(FeatureAvI18nPeer::TITLE)) $criteria->add(FeatureAvI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(FeatureAvI18nPeer::DESCRIPTION)) $criteria->add(FeatureAvI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(FeatureAvI18nPeer::CHAPO)) $criteria->add(FeatureAvI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(FeatureAvI18nPeer::POSTSCRIPTUM)) $criteria->add(FeatureAvI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(FeatureAvI18nPeer::DATABASE_NAME); - $criteria->add(FeatureAvI18nPeer::ID, $this->id); - $criteria->add(FeatureAvI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 FeatureAvI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 FeatureAvI18n 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 FeatureAvI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeatureAvI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a FeatureAv object. - * - * @param FeatureAv $v - * @return FeatureAvI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setFeatureAv(FeatureAv $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aFeatureAv = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the FeatureAv object, it will not be re-added. - if ($v !== null) { - $v->addFeatureAvI18n($this); - } - - - return $this; - } - - - /** - * Get the associated FeatureAv object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return FeatureAv The associated FeatureAv object. - * @throws PropelException - */ - public function getFeatureAv(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeatureAv === null && ($this->id !== null) && $doQuery) { - $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeatureAv->addFeatureAvI18ns($this); - */ - } - - return $this->aFeatureAv; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aFeatureAv instanceof Persistent) { - $this->aFeatureAv->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aFeatureAv = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureAvI18nPeer::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/BaseFeatureAvI18nPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php deleted file mode 100755 index c4144fd24..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (FeatureAvI18nPeer::ID, FeatureAvI18nPeer::LOCALE, FeatureAvI18nPeer::TITLE, FeatureAvI18nPeer::DESCRIPTION, FeatureAvI18nPeer::CHAPO, FeatureAvI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeatureAvI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (FeatureAvI18nPeer::ID => 0, FeatureAvI18nPeer::LOCALE => 1, FeatureAvI18nPeer::TITLE => 2, FeatureAvI18nPeer::DESCRIPTION => 3, FeatureAvI18nPeer::CHAPO => 4, FeatureAvI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeatureAvI18nPeer::getFieldNames($toType); - $key = isset(FeatureAvI18nPeer::$fieldKeys[$fromType][$name]) ? FeatureAvI18nPeer::$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(FeatureAvI18nPeer::$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, FeatureAvI18nPeer::$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 FeatureAvI18nPeer::$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. FeatureAvI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeatureAvI18nPeer::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(FeatureAvI18nPeer::ID); - $criteria->addSelectColumn(FeatureAvI18nPeer::LOCALE); - $criteria->addSelectColumn(FeatureAvI18nPeer::TITLE); - $criteria->addSelectColumn(FeatureAvI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(FeatureAvI18nPeer::CHAPO); - $criteria->addSelectColumn(FeatureAvI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(FeatureAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeatureAvI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::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 FeatureAvI18n - * @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 = FeatureAvI18nPeer::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 FeatureAvI18nPeer::populateObjects(FeatureAvI18nPeer::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 directly (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(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeatureAvI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::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 FeatureAvI18n $obj A FeatureAvI18n 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->getLocale())); - } // if key === null - FeatureAvI18nPeer::$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 FeatureAvI18n 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 FeatureAvI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 FeatureAvI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeatureAvI18nPeer::$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 FeatureAvI18n 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(FeatureAvI18nPeer::$instances[$key])) { - return FeatureAvI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeatureAvI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeatureAvI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature_av_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeatureAvI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeatureAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeatureAvI18nPeer::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; - FeatureAvI18nPeer::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 (FeatureAvI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeatureAvI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeatureAvI18nPeer::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 + FeatureAvI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureAvI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeatureAvI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related FeatureAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureAvI18nPeer::ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureAvI18n objects pre-filled with their FeatureAv objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureAvI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureAvI18nPeer::DATABASE_NAME); - } - - FeatureAvI18nPeer::addSelectColumns($criteria); - $startcol = FeatureAvI18nPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureAvI18nPeer::ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureAvI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureAvI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureAvI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeatureAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureAvI18n) to $obj2 (FeatureAv) - $obj2->addFeatureAvI18n($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(FeatureAvI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureAvI18nPeer::ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of FeatureAvI18n 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 FeatureAvI18n 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(FeatureAvI18nPeer::DATABASE_NAME); - } - - FeatureAvI18nPeer::addSelectColumns($criteria); - $startcol2 = FeatureAvI18nPeer::NUM_HYDRATE_COLUMNS; - - FeatureAvPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureAvI18nPeer::ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureAvI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureAvI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureAvI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureAvI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined FeatureAv rows - - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FeatureAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (FeatureAvI18n) to the collection in $obj2 (FeatureAv) - $obj2->addFeatureAvI18n($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(FeatureAvI18nPeer::DATABASE_NAME)->getTable(FeatureAvI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeatureAvI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeatureAvI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureAvI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeatureAvI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FeatureAvI18n or Criteria object. - * - * @param mixed $values Criteria or FeatureAvI18n 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(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FeatureAvI18n object - } - - - // Set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::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 FeatureAvI18n or Criteria object. - * - * @param mixed $values Criteria or FeatureAvI18n 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(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeatureAvI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeatureAvI18nPeer::ID); - $value = $criteria->remove(FeatureAvI18nPeer::ID); - if ($value) { - $selectCriteria->add(FeatureAvI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureAvI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(FeatureAvI18nPeer::LOCALE); - $value = $criteria->remove(FeatureAvI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(FeatureAvI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureAvI18nPeer::TABLE_NAME); - } - - } else { // $values is FeatureAvI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature_av_i18n 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(FeatureAvI18nPeer::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(FeatureAvI18nPeer::TABLE_NAME, $con, FeatureAvI18nPeer::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). - FeatureAvI18nPeer::clearInstancePool(); - FeatureAvI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FeatureAvI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureAvI18n 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(FeatureAvI18nPeer::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. - FeatureAvI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FeatureAvI18n) { // it's a model object - // invalidate the cache for this single object - FeatureAvI18nPeer::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(FeatureAvI18nPeer::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(FeatureAvI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(FeatureAvI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - FeatureAvI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(FeatureAvI18nPeer::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); - FeatureAvI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FeatureAvI18n 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 FeatureAvI18n $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(FeatureAvI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeatureAvI18nPeer::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(FeatureAvI18nPeer::DATABASE_NAME, FeatureAvI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return FeatureAvI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = FeatureAvI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(FeatureAvI18nPeer::DATABASE_NAME); - $criteria->add(FeatureAvI18nPeer::ID, $id); - $criteria->add(FeatureAvI18nPeer::LOCALE, $locale); - $v = FeatureAvI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseFeatureAvI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeatureAvI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php deleted file mode 100755 index f305575dc..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAvI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return FeatureAvI18n|FeatureAvI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeatureAvI18nPeer::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(FeatureAvI18nPeer::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 FeatureAvI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_av_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 FeatureAvI18n(); - $obj->hydrate($row); - FeatureAvI18nPeer::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 FeatureAvI18n|FeatureAvI18n[]|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|FeatureAvI18n[]|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 FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(FeatureAvI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(FeatureAvI18nPeer::LOCALE, $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 FeatureAvI18nQuery 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(FeatureAvI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(FeatureAvI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByFeatureAv() - * - * @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 FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeatureAvI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeatureAvI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureAvI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related FeatureAv object - * - * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureAv($featureAv, $comparison = null) - { - if ($featureAv instanceof FeatureAv) { - return $this - ->addUsingAlias(FeatureAvI18nPeer::ID, $featureAv->getId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureAvI18nPeer::ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function joinFeatureAv($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureAv'); - } - - return $this; - } - - /** - * Use the FeatureAv relation FeatureAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query - */ - public function useFeatureAvQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFeatureAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); - } - - /** - * Exclude object from result - * - * @param FeatureAvI18n $featureAvI18n Object to remove from the list of results - * - * @return FeatureAvI18nQuery The current query, for fluid interface - */ - public function prune($featureAvI18n = null) - { - if ($featureAvI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(FeatureAvI18nPeer::ID), $featureAvI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(FeatureAvI18nPeer::LOCALE), $featureAvI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php b/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php deleted file mode 100755 index e565a43e0..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAvPeer.php +++ /dev/null @@ -1,1039 +0,0 @@ - array ('Id', 'FeatureId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (FeatureAvPeer::ID, FeatureAvPeer::FEATURE_ID, FeatureAvPeer::CREATED_AT, FeatureAvPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'feature_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeatureAvPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (FeatureAvPeer::ID => 0, FeatureAvPeer::FEATURE_ID => 1, FeatureAvPeer::CREATED_AT => 2, FeatureAvPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeatureAvPeer::getFieldNames($toType); - $key = isset(FeatureAvPeer::$fieldKeys[$fromType][$name]) ? FeatureAvPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureAvPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, FeatureAvPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return FeatureAvPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. FeatureAvPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeatureAvPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(FeatureAvPeer::ID); - $criteria->addSelectColumn(FeatureAvPeer::FEATURE_ID); - $criteria->addSelectColumn(FeatureAvPeer::CREATED_AT); - $criteria->addSelectColumn(FeatureAvPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.feature_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return FeatureAv - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = FeatureAvPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return FeatureAvPeer::populateObjects(FeatureAvPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeatureAvPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param FeatureAv $obj A FeatureAv object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - FeatureAvPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A FeatureAv object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof FeatureAv) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureAv object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeatureAvPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return FeatureAv Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(FeatureAvPeer::$instances[$key])) { - return FeatureAvPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeatureAvPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeatureAvPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature_av - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in FeatureProdPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureProdPeer::clearInstancePool(); - // Invalidate objects in FeatureAvI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureAvI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeatureAvPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeatureAvPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - FeatureAvPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (FeatureAv object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeatureAvPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureAvPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeatureAvPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureAv objects pre-filled with their Feature objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureAv objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - } - - FeatureAvPeer::addSelectColumns($criteria); - $startcol = FeatureAvPeer::NUM_HYDRATE_COLUMNS; - FeaturePeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureAvPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureAvPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureAvPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureAv) to $obj2 (Feature) - $obj2->addFeatureAv($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureAvPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of FeatureAv objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureAv objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - } - - FeatureAvPeer::addSelectColumns($criteria); - $startcol2 = FeatureAvPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureAvPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureAvPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureAvPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureAvPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Feature rows - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (FeatureAv) to the collection in $obj2 (Feature) - $obj2->addFeatureAv($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(FeatureAvPeer::DATABASE_NAME)->getTable(FeatureAvPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeatureAvPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeatureAvPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureAvTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeatureAvPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FeatureAv or Criteria object. - * - * @param mixed $values Criteria or FeatureAv object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FeatureAv object - } - - if ($criteria->containsKey(FeatureAvPeer::ID) && $criteria->keyContainsValue(FeatureAvPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureAvPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a FeatureAv or Criteria object. - * - * @param mixed $values Criteria or FeatureAv object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeatureAvPeer::ID); - $value = $criteria->remove(FeatureAvPeer::ID); - if ($value) { - $selectCriteria->add(FeatureAvPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureAvPeer::TABLE_NAME); - } - - } else { // $values is FeatureAv object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature_av table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(FeatureAvPeer::TABLE_NAME, $con, FeatureAvPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - FeatureAvPeer::clearInstancePool(); - FeatureAvPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FeatureAv or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureAv object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - FeatureAvPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FeatureAv) { // it's a model object - // invalidate the cache for this single object - FeatureAvPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - $criteria->add(FeatureAvPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - FeatureAvPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(FeatureAvPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - FeatureAvPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FeatureAv object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param FeatureAv $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(FeatureAvPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeatureAvPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(FeatureAvPeer::DATABASE_NAME, FeatureAvPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return FeatureAv - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = FeatureAvPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - $criteria->add(FeatureAvPeer::ID, $pk); - - $v = FeatureAvPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return FeatureAv[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(FeatureAvPeer::DATABASE_NAME); - $criteria->add(FeatureAvPeer::ID, $pks, Criteria::IN); - $objs = FeatureAvPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseFeatureAvPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeatureAvPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php b/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php deleted file mode 100755 index 98f1fd0e4..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureAvQuery.php +++ /dev/null @@ -1,790 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeatureAvPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(FeatureAvPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureAv A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureAv A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `feature_id`, `created_at`, `updated_at` FROM `feature_av` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureAv(); - $obj->hydrate($row); - FeatureAvPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureAv|FeatureAv[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|FeatureAv[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(FeatureAvPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(FeatureAvPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeatureAvPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeatureAvPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureAvPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the feature_id column - * - * Example usage: - * - * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 - * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 - * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 - * - * - * @see filterByFeature() - * - * @param mixed $featureId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterByFeatureId($featureId = null, $comparison = null) - { - if (is_array($featureId)) { - $useMinMax = false; - if (isset($featureId['min'])) { - $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureAvPeer::FEATURE_ID, $featureId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureAvPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Feature object - * - * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeature($feature, $comparison = null) - { - if ($feature instanceof Feature) { - return $this - ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureAvPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Feature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Feature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Feature'); - } - - return $this; - } - - /** - * Use the Feature relation Feature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query - */ - public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); - } - - /** - * Filter the query by a related FeatureProd object - * - * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureProd($featureProd, $comparison = null) - { - if ($featureProd instanceof FeatureProd) { - return $this - ->addUsingAlias(FeatureAvPeer::ID, $featureProd->getFeatureAvId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { - return $this - ->useFeatureProdQuery() - ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureProd relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function joinFeatureProd($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureProd'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureProd'); - } - - return $this; - } - - /** - * Use the FeatureProd relation FeatureProd object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query - */ - public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFeatureProd($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); - } - - /** - * Filter the query by a related FeatureAvI18n object - * - * @param FeatureAvI18n|PropelObjectCollection $featureAvI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureAvQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureAvI18n($featureAvI18n, $comparison = null) - { - if ($featureAvI18n instanceof FeatureAvI18n) { - return $this - ->addUsingAlias(FeatureAvPeer::ID, $featureAvI18n->getId(), $comparison); - } elseif ($featureAvI18n instanceof PropelObjectCollection) { - return $this - ->useFeatureAvI18nQuery() - ->filterByPrimaryKeys($featureAvI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureAvI18n() only accepts arguments of type FeatureAvI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureAvI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function joinFeatureAvI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAvI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureAvI18n'); - } - - return $this; - } - - /** - * Use the FeatureAvI18n relation FeatureAvI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureAvI18nQuery A secondary query class using the current class as primary query - */ - public function useFeatureAvI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFeatureAvI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', '\Thelia\Model\FeatureAvI18nQuery'); - } - - /** - * Exclude object from result - * - * @param FeatureAv $featureAv Object to remove from the list of results - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function prune($featureAv = null) - { - if ($featureAv) { - $this->addUsingAlias(FeatureAvPeer::ID, $featureAv->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(FeatureAvPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureAvPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureAvPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(FeatureAvPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureAvPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureAvPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; - - return $this - ->joinFeatureAvI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureAvQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('FeatureAvI18n'); - $this->with['FeatureAvI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureAvI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAvI18n', 'Thelia\Model\FeatureAvI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategory.php b/core/lib/Thelia/Model/om/BaseFeatureCategory.php deleted file mode 100755 index ffdd4ef02..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureCategory.php +++ /dev/null @@ -1,1287 +0,0 @@ -id; - } - - /** - * Get the [feature_id] column value. - * - * @return int - */ - public function getFeatureId() - { - return $this->feature_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FeatureCategory The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeatureCategoryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [feature_id] column. - * - * @param int $v new value - * @return FeatureCategory The current object (for fluent API support) - */ - public function setFeatureId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->feature_id !== $v) { - $this->feature_id = $v; - $this->modifiedColumns[] = FeatureCategoryPeer::FEATURE_ID; - } - - if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { - $this->aFeature = null; - } - - - return $this; - } // setFeatureId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return FeatureCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = FeatureCategoryPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureCategory The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = FeatureCategoryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureCategory The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = FeatureCategoryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->feature_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->created_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->updated_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FeatureCategory object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { - $this->aFeature = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = FeatureCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCategory = null; - $this->aFeature = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureCategoryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - FeatureCategoryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aFeature !== null) { - if ($this->aFeature->isModified() || $this->aFeature->isNew()) { - $affectedRows += $this->aFeature->save($con); - } - $this->setFeature($this->aFeature); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = FeatureCategoryPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureCategoryPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureCategoryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeatureCategoryPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_id`'; - } - if ($this->isColumnModified(FeatureCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `feature_category` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`feature_id`': - $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aFeature !== null) { - if (!$this->aFeature->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures()); - } - } - - - if (($retval = FeatureCategoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getFeatureId(); - break; - case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureCategory'][$this->getPrimaryKey()] = true; - $keys = FeatureCategoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getFeatureId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFeature) { - $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setFeatureId($value); - break; - case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = FeatureCategoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(FeatureCategoryPeer::ID)) $criteria->add(FeatureCategoryPeer::ID, $this->id); - if ($this->isColumnModified(FeatureCategoryPeer::FEATURE_ID)) $criteria->add(FeatureCategoryPeer::FEATURE_ID, $this->feature_id); - if ($this->isColumnModified(FeatureCategoryPeer::CATEGORY_ID)) $criteria->add(FeatureCategoryPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(FeatureCategoryPeer::CREATED_AT)) $criteria->add(FeatureCategoryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeatureCategoryPeer::UPDATED_AT)) $criteria->add(FeatureCategoryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - $criteria->add(FeatureCategoryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of FeatureCategory (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setFeatureId($this->getFeatureId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return FeatureCategory Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return FeatureCategoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeatureCategoryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return FeatureCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addFeatureCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addFeatureCategorys($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Feature object. - * - * @param Feature $v - * @return FeatureCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setFeature(Feature $v = null) - { - if ($v === null) { - $this->setFeatureId(NULL); - } else { - $this->setFeatureId($v->getId()); - } - - $this->aFeature = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Feature object, it will not be re-added. - if ($v !== null) { - $v->addFeatureCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Feature object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. - * @throws PropelException - */ - public function getFeature(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeature->addFeatureCategorys($this); - */ - } - - return $this->aFeature; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->feature_id = null; - $this->category_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aFeature instanceof Persistent) { - $this->aFeature->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCategory = null; - $this->aFeature = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureCategoryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return FeatureCategory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FeatureCategoryPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php deleted file mode 100755 index 2dfa0e579..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryPeer.php +++ /dev/null @@ -1,1423 +0,0 @@ - array ('Id', 'FeatureId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'featureId', 'categoryId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (FeatureCategoryPeer::ID, FeatureCategoryPeer::FEATURE_ID, FeatureCategoryPeer::CATEGORY_ID, FeatureCategoryPeer::CREATED_AT, FeatureCategoryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'FEATURE_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'feature_id', 'category_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeatureCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'FeatureId' => 1, 'CategoryId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'featureId' => 1, 'categoryId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (FeatureCategoryPeer::ID => 0, FeatureCategoryPeer::FEATURE_ID => 1, FeatureCategoryPeer::CATEGORY_ID => 2, FeatureCategoryPeer::CREATED_AT => 3, FeatureCategoryPeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'FEATURE_ID' => 1, 'CATEGORY_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'feature_id' => 1, 'category_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeatureCategoryPeer::getFieldNames($toType); - $key = isset(FeatureCategoryPeer::$fieldKeys[$fromType][$name]) ? FeatureCategoryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureCategoryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, FeatureCategoryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return FeatureCategoryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. FeatureCategoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeatureCategoryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(FeatureCategoryPeer::ID); - $criteria->addSelectColumn(FeatureCategoryPeer::FEATURE_ID); - $criteria->addSelectColumn(FeatureCategoryPeer::CATEGORY_ID); - $criteria->addSelectColumn(FeatureCategoryPeer::CREATED_AT); - $criteria->addSelectColumn(FeatureCategoryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.feature_id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return FeatureCategory - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = FeatureCategoryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return FeatureCategoryPeer::populateObjects(FeatureCategoryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeatureCategoryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param FeatureCategory $obj A FeatureCategory object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - FeatureCategoryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A FeatureCategory object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof FeatureCategory) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeatureCategoryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return FeatureCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(FeatureCategoryPeer::$instances[$key])) { - return FeatureCategoryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeatureCategoryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeatureCategoryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature_category - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeatureCategoryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - FeatureCategoryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (FeatureCategory object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureCategoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeatureCategoryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureCategory objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - } - - FeatureCategoryPeer::addSelectColumns($criteria); - $startcol = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureCategory) to $obj2 (Category) - $obj2->addFeatureCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureCategory objects pre-filled with their Feature objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - } - - FeatureCategoryPeer::addSelectColumns($criteria); - $startcol = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - FeaturePeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureCategory) to $obj2 (Feature) - $obj2->addFeatureCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of FeatureCategory objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - } - - FeatureCategoryPeer::addSelectColumns($criteria); - $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Category) - $obj2->addFeatureCategory($obj1); - } // if joined row not null - - // Add objects for joined Feature rows - - $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FeaturePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FeaturePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FeaturePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (FeatureCategory) to the collection in $obj3 (Feature) - $obj3->addFeatureCategory($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureCategory objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - } - - FeatureCategoryPeer::addSelectColumns($criteria); - $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureCategoryPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Feature rows - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Feature) - $obj2->addFeatureCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureCategory objects pre-filled with all related objects except Feature. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - } - - FeatureCategoryPeer::addSelectColumns($criteria); - $startcol2 = FeatureCategoryPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (FeatureCategory) to the collection in $obj2 (Category) - $obj2->addFeatureCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(FeatureCategoryPeer::DATABASE_NAME)->getTable(FeatureCategoryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeatureCategoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeatureCategoryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureCategoryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeatureCategoryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FeatureCategory or Criteria object. - * - * @param mixed $values Criteria or FeatureCategory object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FeatureCategory object - } - - if ($criteria->containsKey(FeatureCategoryPeer::ID) && $criteria->keyContainsValue(FeatureCategoryPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureCategoryPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a FeatureCategory or Criteria object. - * - * @param mixed $values Criteria or FeatureCategory object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeatureCategoryPeer::ID); - $value = $criteria->remove(FeatureCategoryPeer::ID); - if ($value) { - $selectCriteria->add(FeatureCategoryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureCategoryPeer::TABLE_NAME); - } - - } else { // $values is FeatureCategory object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature_category table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(FeatureCategoryPeer::TABLE_NAME, $con, FeatureCategoryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - FeatureCategoryPeer::clearInstancePool(); - FeatureCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FeatureCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureCategory object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - FeatureCategoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FeatureCategory) { // it's a model object - // invalidate the cache for this single object - FeatureCategoryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - $criteria->add(FeatureCategoryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - FeatureCategoryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(FeatureCategoryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - FeatureCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FeatureCategory object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param FeatureCategory $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(FeatureCategoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeatureCategoryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(FeatureCategoryPeer::DATABASE_NAME, FeatureCategoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return FeatureCategory - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = FeatureCategoryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - $criteria->add(FeatureCategoryPeer::ID, $pk); - - $v = FeatureCategoryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return FeatureCategory[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(FeatureCategoryPeer::DATABASE_NAME); - $criteria->add(FeatureCategoryPeer::ID, $pks, Criteria::IN); - $objs = FeatureCategoryPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseFeatureCategoryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeatureCategoryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php b/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php deleted file mode 100755 index f0481ff21..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureCategoryQuery.php +++ /dev/null @@ -1,704 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeatureCategoryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(FeatureCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureCategory A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureCategory A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `feature_id`, `category_id`, `created_at`, `updated_at` FROM `feature_category` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureCategory(); - $obj->hydrate($row); - FeatureCategoryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureCategory|FeatureCategory[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|FeatureCategory[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(FeatureCategoryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(FeatureCategoryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeatureCategoryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureCategoryPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the feature_id column - * - * Example usage: - * - * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 - * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 - * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 - * - * - * @see filterByFeature() - * - * @param mixed $featureId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByFeatureId($featureId = null, $comparison = null) - { - if (is_array($featureId)) { - $useMinMax = false; - if (isset($featureId['min'])) { - $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $featureId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Feature object - * - * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeature($feature, $comparison = null) - { - if ($feature instanceof Feature) { - return $this - ->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureCategoryPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Feature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Feature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Feature'); - } - - return $this; - } - - /** - * Use the Feature relation Feature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query - */ - public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); - } - - /** - * Exclude object from result - * - * @param FeatureCategory $featureCategory Object to remove from the list of results - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function prune($featureCategory = null) - { - if ($featureCategory) { - $this->addUsingAlias(FeatureCategoryPeer::ID, $featureCategory->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(FeatureCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureCategoryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureCategoryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(FeatureCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return FeatureCategoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureCategoryPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18n.php b/core/lib/Thelia/Model/om/BaseFeatureI18n.php deleted file mode 100755 index 5a18b0ade..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseFeatureI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeatureI18nPeer::ID; - } - - if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { - $this->aFeature = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = FeatureI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = FeatureI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = FeatureI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = FeatureI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FeatureI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = FeatureI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = FeatureI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FeatureI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aFeature !== null && $this->id !== $this->aFeature->getId()) { - $this->aFeature = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::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 = FeatureI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aFeature = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureI18nQuery::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(FeatureI18nPeer::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); - FeatureI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeature !== null) { - if ($this->aFeature->isModified() || $this->aFeature->isNew()) { - $affectedRows += $this->aFeature->save($con); - } - $this->setFeature($this->aFeature); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeatureI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(FeatureI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(FeatureI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(FeatureI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(FeatureI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `feature_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aFeature !== null) { - if (!$this->aFeature->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures()); - } - } - - - if (($retval = FeatureI18nPeer::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 = FeatureI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['FeatureI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureI18n'][serialize($this->getPrimaryKey())] = true; - $keys = FeatureI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aFeature) { - $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = FeatureI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeatureI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(FeatureI18nPeer::ID)) $criteria->add(FeatureI18nPeer::ID, $this->id); - if ($this->isColumnModified(FeatureI18nPeer::LOCALE)) $criteria->add(FeatureI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(FeatureI18nPeer::TITLE)) $criteria->add(FeatureI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(FeatureI18nPeer::DESCRIPTION)) $criteria->add(FeatureI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(FeatureI18nPeer::CHAPO)) $criteria->add(FeatureI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(FeatureI18nPeer::POSTSCRIPTUM)) $criteria->add(FeatureI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(FeatureI18nPeer::DATABASE_NAME); - $criteria->add(FeatureI18nPeer::ID, $this->id); - $criteria->add(FeatureI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 FeatureI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 FeatureI18n 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 FeatureI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeatureI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Feature object. - * - * @param Feature $v - * @return FeatureI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setFeature(Feature $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aFeature = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Feature object, it will not be re-added. - if ($v !== null) { - $v->addFeatureI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Feature object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. - * @throws PropelException - */ - public function getFeature(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeature === null && ($this->id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeature->addFeatureI18ns($this); - */ - } - - return $this->aFeature; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aFeature instanceof Persistent) { - $this->aFeature->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aFeature = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureI18nPeer::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/BaseFeatureI18nPeer.php b/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php deleted file mode 100755 index 38d7a6f4d..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (FeatureI18nPeer::ID, FeatureI18nPeer::LOCALE, FeatureI18nPeer::TITLE, FeatureI18nPeer::DESCRIPTION, FeatureI18nPeer::CHAPO, FeatureI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeatureI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (FeatureI18nPeer::ID => 0, FeatureI18nPeer::LOCALE => 1, FeatureI18nPeer::TITLE => 2, FeatureI18nPeer::DESCRIPTION => 3, FeatureI18nPeer::CHAPO => 4, FeatureI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeatureI18nPeer::getFieldNames($toType); - $key = isset(FeatureI18nPeer::$fieldKeys[$fromType][$name]) ? FeatureI18nPeer::$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(FeatureI18nPeer::$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, FeatureI18nPeer::$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 FeatureI18nPeer::$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. FeatureI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeatureI18nPeer::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(FeatureI18nPeer::ID); - $criteria->addSelectColumn(FeatureI18nPeer::LOCALE); - $criteria->addSelectColumn(FeatureI18nPeer::TITLE); - $criteria->addSelectColumn(FeatureI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(FeatureI18nPeer::CHAPO); - $criteria->addSelectColumn(FeatureI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(FeatureI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeatureI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::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 FeatureI18n - * @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 = FeatureI18nPeer::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 FeatureI18nPeer::populateObjects(FeatureI18nPeer::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 directly (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(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeatureI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeatureI18nPeer::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 FeatureI18n $obj A FeatureI18n 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->getLocale())); - } // if key === null - FeatureI18nPeer::$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 FeatureI18n 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 FeatureI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 FeatureI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeatureI18nPeer::$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 FeatureI18n 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(FeatureI18nPeer::$instances[$key])) { - return FeatureI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeatureI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeatureI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeatureI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeatureI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeatureI18nPeer::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; - FeatureI18nPeer::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 (FeatureI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeatureI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeatureI18nPeer::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 + FeatureI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeatureI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureI18nPeer::ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureI18n objects pre-filled with their Feature objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureI18nPeer::DATABASE_NAME); - } - - FeatureI18nPeer::addSelectColumns($criteria); - $startcol = FeatureI18nPeer::NUM_HYDRATE_COLUMNS; - FeaturePeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureI18nPeer::ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureI18n) to $obj2 (Feature) - $obj2->addFeatureI18n($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(FeatureI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureI18nPeer::ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of FeatureI18n 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 FeatureI18n 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(FeatureI18nPeer::DATABASE_NAME); - } - - FeatureI18nPeer::addSelectColumns($criteria); - $startcol2 = FeatureI18nPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureI18nPeer::ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Feature rows - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (FeatureI18n) to the collection in $obj2 (Feature) - $obj2->addFeatureI18n($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(FeatureI18nPeer::DATABASE_NAME)->getTable(FeatureI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeatureI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeatureI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeatureI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FeatureI18n or Criteria object. - * - * @param mixed $values Criteria or FeatureI18n 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(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FeatureI18n object - } - - - // Set the correct dbName - $criteria->setDbName(FeatureI18nPeer::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 FeatureI18n or Criteria object. - * - * @param mixed $values Criteria or FeatureI18n 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(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeatureI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeatureI18nPeer::ID); - $value = $criteria->remove(FeatureI18nPeer::ID); - if ($value) { - $selectCriteria->add(FeatureI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(FeatureI18nPeer::LOCALE); - $value = $criteria->remove(FeatureI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(FeatureI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureI18nPeer::TABLE_NAME); - } - - } else { // $values is FeatureI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeatureI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature_i18n 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(FeatureI18nPeer::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(FeatureI18nPeer::TABLE_NAME, $con, FeatureI18nPeer::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). - FeatureI18nPeer::clearInstancePool(); - FeatureI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FeatureI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureI18n 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(FeatureI18nPeer::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. - FeatureI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FeatureI18n) { // it's a model object - // invalidate the cache for this single object - FeatureI18nPeer::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(FeatureI18nPeer::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(FeatureI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(FeatureI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - FeatureI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(FeatureI18nPeer::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); - FeatureI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FeatureI18n 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 FeatureI18n $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(FeatureI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeatureI18nPeer::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(FeatureI18nPeer::DATABASE_NAME, FeatureI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return FeatureI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = FeatureI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeatureI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(FeatureI18nPeer::DATABASE_NAME); - $criteria->add(FeatureI18nPeer::ID, $id); - $criteria->add(FeatureI18nPeer::LOCALE, $locale); - $v = FeatureI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseFeatureI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeatureI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php b/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php deleted file mode 100755 index d07e8d108..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return FeatureI18n|FeatureI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeatureI18nPeer::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(FeatureI18nPeer::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 FeatureI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `feature_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 FeatureI18n(); - $obj->hydrate($row); - FeatureI18nPeer::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 FeatureI18n|FeatureI18n[]|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|FeatureI18n[]|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 FeatureI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(FeatureI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(FeatureI18nPeer::LOCALE, $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 FeatureI18nQuery 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(FeatureI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(FeatureI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByFeature() - * - * @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 FeatureI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeatureI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeatureI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 FeatureI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Feature object - * - * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeature($feature, $comparison = null) - { - if ($feature instanceof Feature) { - return $this - ->addUsingAlias(FeatureI18nPeer::ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureI18nPeer::ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Feature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function joinFeature($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Feature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Feature'); - } - - return $this; - } - - /** - * Use the Feature relation Feature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query - */ - public function useFeatureQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); - } - - /** - * Exclude object from result - * - * @param FeatureI18n $featureI18n Object to remove from the list of results - * - * @return FeatureI18nQuery The current query, for fluid interface - */ - public function prune($featureI18n = null) - { - if ($featureI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(FeatureI18nPeer::ID), $featureI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(FeatureI18nPeer::LOCALE), $featureI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeaturePeer.php b/core/lib/Thelia/Model/om/BaseFeaturePeer.php deleted file mode 100755 index 954bb2e0e..000000000 --- a/core/lib/Thelia/Model/om/BaseFeaturePeer.php +++ /dev/null @@ -1,813 +0,0 @@ - array ('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'visible', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (FeaturePeer::ID, FeaturePeer::VISIBLE, FeaturePeer::POSITION, FeaturePeer::CREATED_AT, FeaturePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'visible', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeaturePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - BasePeer::TYPE_COLNAME => array (FeaturePeer::ID => 0, FeaturePeer::VISIBLE => 1, FeaturePeer::POSITION => 2, FeaturePeer::CREATED_AT => 3, FeaturePeer::UPDATED_AT => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeaturePeer::getFieldNames($toType); - $key = isset(FeaturePeer::$fieldKeys[$fromType][$name]) ? FeaturePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeaturePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, FeaturePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return FeaturePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. FeaturePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeaturePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(FeaturePeer::ID); - $criteria->addSelectColumn(FeaturePeer::VISIBLE); - $criteria->addSelectColumn(FeaturePeer::POSITION); - $criteria->addSelectColumn(FeaturePeer::CREATED_AT); - $criteria->addSelectColumn(FeaturePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.visible'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeaturePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeaturePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeaturePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Feature - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = FeaturePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return FeaturePeer::populateObjects(FeaturePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeaturePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeaturePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Feature $obj A Feature object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - FeaturePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Feature object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Feature) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Feature object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeaturePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Feature Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(FeaturePeer::$instances[$key])) { - return FeaturePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeaturePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeaturePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in FeatureAvPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureAvPeer::clearInstancePool(); - // Invalidate objects in FeatureProdPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureProdPeer::clearInstancePool(); - // Invalidate objects in FeatureCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureCategoryPeer::clearInstancePool(); - // Invalidate objects in FeatureI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeaturePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeaturePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeaturePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - FeaturePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Feature object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeaturePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + FeaturePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeaturePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeaturePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(FeaturePeer::DATABASE_NAME)->getTable(FeaturePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeaturePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeaturePeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeaturePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Feature or Criteria object. - * - * @param mixed $values Criteria or Feature object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Feature object - } - - if ($criteria->containsKey(FeaturePeer::ID) && $criteria->keyContainsValue(FeaturePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeaturePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(FeaturePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Feature or Criteria object. - * - * @param mixed $values Criteria or Feature object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeaturePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeaturePeer::ID); - $value = $criteria->remove(FeaturePeer::ID); - if ($value) { - $selectCriteria->add(FeaturePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeaturePeer::TABLE_NAME); - } - - } else { // $values is Feature object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeaturePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(FeaturePeer::TABLE_NAME, $con, FeaturePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - FeaturePeer::clearInstancePool(); - FeaturePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Feature or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Feature object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - FeaturePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Feature) { // it's a model object - // invalidate the cache for this single object - FeaturePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - $criteria->add(FeaturePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - FeaturePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(FeaturePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - FeaturePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Feature object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Feature $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(FeaturePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeaturePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(FeaturePeer::DATABASE_NAME, FeaturePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Feature - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = FeaturePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - $criteria->add(FeaturePeer::ID, $pk); - - $v = FeaturePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Feature[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(FeaturePeer::DATABASE_NAME); - $criteria->add(FeaturePeer::ID, $pks, Criteria::IN); - $objs = FeaturePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseFeaturePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeaturePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureProd.php b/core/lib/Thelia/Model/om/BaseFeatureProd.php deleted file mode 100755 index 68d6f9ce0..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureProd.php +++ /dev/null @@ -1,1539 +0,0 @@ -id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [feature_id] column value. - * - * @return int - */ - public function getFeatureId() - { - return $this->feature_id; - } - - /** - * Get the [feature_av_id] column value. - * - * @return int - */ - public function getFeatureAvId() - { - return $this->feature_av_id; - } - - /** - * Get the [by_default] column value. - * - * @return string - */ - public function getByDefault() - { - return $this->by_default; - } - - /** - * 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FeatureProdPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [feature_id] column. - * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setFeatureId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->feature_id !== $v) { - $this->feature_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::FEATURE_ID; - } - - if ($this->aFeature !== null && $this->aFeature->getId() !== $v) { - $this->aFeature = null; - } - - - return $this; - } // setFeatureId() - - /** - * Set the value of [feature_av_id] column. - * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setFeatureAvId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->feature_av_id !== $v) { - $this->feature_av_id = $v; - $this->modifiedColumns[] = FeatureProdPeer::FEATURE_AV_ID; - } - - if ($this->aFeatureAv !== null && $this->aFeatureAv->getId() !== $v) { - $this->aFeatureAv = null; - } - - - return $this; - } // setFeatureAvId() - - /** - * Set the value of [by_default] column. - * - * @param string $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setByDefault($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = FeatureProdPeer::BY_DEFAULT; - } - - - return $this; - } // setByDefault() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return FeatureProd The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = FeatureProdPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureProd The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = FeatureProdPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return FeatureProd The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = FeatureProdPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->feature_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->feature_av_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->by_default = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->position = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = FeatureProdPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FeatureProd object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aFeature !== null && $this->feature_id !== $this->aFeature->getId()) { - $this->aFeature = null; - } - if ($this->aFeatureAv !== null && $this->feature_av_id !== $this->aFeatureAv->getId()) { - $this->aFeatureAv = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = FeatureProdPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aFeature = null; - $this->aFeatureAv = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FeatureProdQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(FeatureProdPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - FeatureProdPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aFeature !== null) { - if ($this->aFeature->isModified() || $this->aFeature->isNew()) { - $affectedRows += $this->aFeature->save($con); - } - $this->setFeature($this->aFeature); - } - - if ($this->aFeatureAv !== null) { - if ($this->aFeatureAv->isModified() || $this->aFeatureAv->isNew()) { - $affectedRows += $this->aFeatureAv->save($con); - } - $this->setFeatureAv($this->aFeatureAv); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = FeatureProdPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FeatureProdPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FeatureProdPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_id`'; - } - if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) { - $modifiedColumns[':p' . $index++] = '`feature_av_id`'; - } - if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; - } - if ($this->isColumnModified(FeatureProdPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `feature_prod` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`feature_id`': - $stmt->bindValue($identifier, $this->feature_id, PDO::PARAM_INT); - break; - case '`feature_av_id`': - $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); - break; - case '`by_default`': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aFeature !== null) { - if (!$this->aFeature->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeature->getValidationFailures()); - } - } - - if ($this->aFeatureAv !== null) { - if (!$this->aFeatureAv->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFeatureAv->getValidationFailures()); - } - } - - - if (($retval = FeatureProdPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getProductId(); - break; - case 2: - return $this->getFeatureId(); - break; - case 3: - return $this->getFeatureAvId(); - break; - case 4: - return $this->getByDefault(); - break; - case 5: - return $this->getPosition(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FeatureProd'][$this->getPrimaryKey()] = true; - $keys = FeatureProdPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getProductId(), - $keys[2] => $this->getFeatureId(), - $keys[3] => $this->getFeatureAvId(), - $keys[4] => $this->getByDefault(), - $keys[5] => $this->getPosition(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFeature) { - $result['Feature'] = $this->aFeature->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFeatureAv) { - $result['FeatureAv'] = $this->aFeatureAv->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FeatureProdPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setProductId($value); - break; - case 2: - $this->setFeatureId($value); - break; - case 3: - $this->setFeatureAvId($value); - break; - case 4: - $this->setByDefault($value); - break; - case 5: - $this->setPosition($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = FeatureProdPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - - if ($this->isColumnModified(FeatureProdPeer::ID)) $criteria->add(FeatureProdPeer::ID, $this->id); - if ($this->isColumnModified(FeatureProdPeer::PRODUCT_ID)) $criteria->add(FeatureProdPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(FeatureProdPeer::FEATURE_ID)) $criteria->add(FeatureProdPeer::FEATURE_ID, $this->feature_id); - if ($this->isColumnModified(FeatureProdPeer::FEATURE_AV_ID)) $criteria->add(FeatureProdPeer::FEATURE_AV_ID, $this->feature_av_id); - if ($this->isColumnModified(FeatureProdPeer::BY_DEFAULT)) $criteria->add(FeatureProdPeer::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(FeatureProdPeer::POSITION)) $criteria->add(FeatureProdPeer::POSITION, $this->position); - if ($this->isColumnModified(FeatureProdPeer::CREATED_AT)) $criteria->add(FeatureProdPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FeatureProdPeer::UPDATED_AT)) $criteria->add(FeatureProdPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - $criteria->add(FeatureProdPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of FeatureProd (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setProductId($this->getProductId()); - $copyObj->setFeatureId($this->getFeatureId()); - $copyObj->setFeatureAvId($this->getFeatureAvId()); - $copyObj->setByDefault($this->getByDefault()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return FeatureProd Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return FeatureProdPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FeatureProdPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return FeatureProd The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addFeatureProd($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addFeatureProds($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Feature object. - * - * @param Feature $v - * @return FeatureProd The current object (for fluent API support) - * @throws PropelException - */ - public function setFeature(Feature $v = null) - { - if ($v === null) { - $this->setFeatureId(NULL); - } else { - $this->setFeatureId($v->getId()); - } - - $this->aFeature = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Feature object, it will not be re-added. - if ($v !== null) { - $v->addFeatureProd($this); - } - - - return $this; - } - - - /** - * Get the associated Feature object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Feature The associated Feature object. - * @throws PropelException - */ - public function getFeature(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeature === null && ($this->feature_id !== null) && $doQuery) { - $this->aFeature = FeatureQuery::create()->findPk($this->feature_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeature->addFeatureProds($this); - */ - } - - return $this->aFeature; - } - - /** - * Declares an association between this object and a FeatureAv object. - * - * @param FeatureAv $v - * @return FeatureProd The current object (for fluent API support) - * @throws PropelException - */ - public function setFeatureAv(FeatureAv $v = null) - { - if ($v === null) { - $this->setFeatureAvId(NULL); - } else { - $this->setFeatureAvId($v->getId()); - } - - $this->aFeatureAv = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the FeatureAv object, it will not be re-added. - if ($v !== null) { - $v->addFeatureProd($this); - } - - - return $this; - } - - - /** - * Get the associated FeatureAv object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return FeatureAv The associated FeatureAv object. - * @throws PropelException - */ - public function getFeatureAv(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFeatureAv === null && ($this->feature_av_id !== null) && $doQuery) { - $this->aFeatureAv = FeatureAvQuery::create()->findPk($this->feature_av_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFeatureAv->addFeatureProds($this); - */ - } - - return $this->aFeatureAv; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->product_id = null; - $this->feature_id = null; - $this->feature_av_id = null; - $this->by_default = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aFeature instanceof Persistent) { - $this->aFeature->clearAllReferences($deep); - } - if ($this->aFeatureAv instanceof Persistent) { - $this->aFeatureAv->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aProduct = null; - $this->aFeature = null; - $this->aFeatureAv = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FeatureProdPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return FeatureProd The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FeatureProdPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php b/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php deleted file mode 100755 index 38323da0e..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureProdPeer.php +++ /dev/null @@ -1,1785 +0,0 @@ - array ('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID, FeatureProdPeer::PRODUCT_ID, FeatureProdPeer::FEATURE_ID, FeatureProdPeer::FEATURE_AV_ID, FeatureProdPeer::BY_DEFAULT, FeatureProdPeer::POSITION, FeatureProdPeer::CREATED_AT, FeatureProdPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FeatureProdPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (FeatureProdPeer::ID => 0, FeatureProdPeer::PRODUCT_ID => 1, FeatureProdPeer::FEATURE_ID => 2, FeatureProdPeer::FEATURE_AV_ID => 3, FeatureProdPeer::BY_DEFAULT => 4, FeatureProdPeer::POSITION => 5, FeatureProdPeer::CREATED_AT => 6, FeatureProdPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FeatureProdPeer::getFieldNames($toType); - $key = isset(FeatureProdPeer::$fieldKeys[$fromType][$name]) ? FeatureProdPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FeatureProdPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, FeatureProdPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return FeatureProdPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. FeatureProdPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FeatureProdPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(FeatureProdPeer::ID); - $criteria->addSelectColumn(FeatureProdPeer::PRODUCT_ID); - $criteria->addSelectColumn(FeatureProdPeer::FEATURE_ID); - $criteria->addSelectColumn(FeatureProdPeer::FEATURE_AV_ID); - $criteria->addSelectColumn(FeatureProdPeer::BY_DEFAULT); - $criteria->addSelectColumn(FeatureProdPeer::POSITION); - $criteria->addSelectColumn(FeatureProdPeer::CREATED_AT); - $criteria->addSelectColumn(FeatureProdPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.feature_id'); - $criteria->addSelectColumn($alias . '.feature_av_id'); - $criteria->addSelectColumn($alias . '.by_default'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return FeatureProd - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = FeatureProdPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return FeatureProdPeer::populateObjects(FeatureProdPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FeatureProdPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param FeatureProd $obj A FeatureProd object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - FeatureProdPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A FeatureProd object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof FeatureProd) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or FeatureProd object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FeatureProdPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return FeatureProd Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(FeatureProdPeer::$instances[$key])) { - return FeatureProdPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FeatureProdPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FeatureProdPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to feature_prod - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FeatureProdPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FeatureProdPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - FeatureProdPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (FeatureProd object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FeatureProdPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FeatureProdPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + FeatureProdPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FeatureProdPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FeatureProdPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related FeatureAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureProd) to $obj2 (Product) - $obj2->addFeatureProd($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with their Feature objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeaturePeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureProd) to $obj2 (Feature) - $obj2->addFeatureProd($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with their FeatureAv objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - FeatureAvPeer::addSelectColumns($criteria); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FeatureAvPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FeatureAvPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (FeatureProd) to $obj2 (FeatureAv) - $obj2->addFeatureProd($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of FeatureProd objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - FeatureAvPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // 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 (FeatureProd) to the collection in $obj2 (Product) - $obj2->addFeatureProd($obj1); - } // if joined row not null - - // Add objects for joined Feature rows - - $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FeaturePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FeaturePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FeaturePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj3 (Feature) - $obj3->addFeatureProd($obj1); - } // if joined row not null - - // Add objects for joined FeatureAv rows - - $key4 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FeatureAvPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FeatureAvPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj4 (FeatureAv) - $obj4->addFeatureProd($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Feature table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFeature(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related FeatureAv table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFeatureAv(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FeatureProdPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - FeatureAvPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Feature rows - - $key2 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = FeaturePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FeaturePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - FeaturePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj2 (Feature) - $obj2->addFeatureProd($obj1); - - } // if joined row is not null - - // Add objects for joined FeatureAv rows - - $key3 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FeatureAvPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FeatureAvPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj3 (FeatureAv) - $obj3->addFeatureProd($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with all related objects except Feature. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFeature(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - FeatureAvPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FeatureAvPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_AV_ID, FeatureAvPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj2 (Product) - $obj2->addFeatureProd($obj1); - - } // if joined row is not null - - // Add objects for joined FeatureAv rows - - $key3 = FeatureAvPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FeatureAvPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FeatureAvPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FeatureAvPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj3 (FeatureAv) - $obj3->addFeatureProd($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of FeatureProd objects pre-filled with all related objects except FeatureAv. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of FeatureProd objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFeatureAv(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - } - - FeatureProdPeer::addSelectColumns($criteria); - $startcol2 = FeatureProdPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - FeaturePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FeaturePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FeatureProdPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(FeatureProdPeer::FEATURE_ID, FeaturePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FeatureProdPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FeatureProdPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FeatureProdPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj2 (Product) - $obj2->addFeatureProd($obj1); - - } // if joined row is not null - - // Add objects for joined Feature rows - - $key3 = FeaturePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FeaturePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FeaturePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FeaturePeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (FeatureProd) to the collection in $obj3 (Feature) - $obj3->addFeatureProd($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(FeatureProdPeer::DATABASE_NAME)->getTable(FeatureProdPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFeatureProdPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFeatureProdPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FeatureProdTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FeatureProdPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FeatureProd or Criteria object. - * - * @param mixed $values Criteria or FeatureProd object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FeatureProd object - } - - if ($criteria->containsKey(FeatureProdPeer::ID) && $criteria->keyContainsValue(FeatureProdPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FeatureProdPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a FeatureProd or Criteria object. - * - * @param mixed $values Criteria or FeatureProd object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FeatureProdPeer::ID); - $value = $criteria->remove(FeatureProdPeer::ID); - if ($value) { - $selectCriteria->add(FeatureProdPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FeatureProdPeer::TABLE_NAME); - } - - } else { // $values is FeatureProd object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the feature_prod table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(FeatureProdPeer::TABLE_NAME, $con, FeatureProdPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - FeatureProdPeer::clearInstancePool(); - FeatureProdPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FeatureProd or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FeatureProd object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - FeatureProdPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FeatureProd) { // it's a model object - // invalidate the cache for this single object - FeatureProdPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - $criteria->add(FeatureProdPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - FeatureProdPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(FeatureProdPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - FeatureProdPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FeatureProd object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param FeatureProd $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(FeatureProdPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FeatureProdPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(FeatureProdPeer::DATABASE_NAME, FeatureProdPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return FeatureProd - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = FeatureProdPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - $criteria->add(FeatureProdPeer::ID, $pk); - - $v = FeatureProdPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return FeatureProd[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(FeatureProdPeer::DATABASE_NAME); - $criteria->add(FeatureProdPeer::ID, $pks, Criteria::IN); - $objs = FeatureProdPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseFeatureProdPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFeatureProdPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php b/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php deleted file mode 100755 index 761bacb44..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureProdQuery.php +++ /dev/null @@ -1,912 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeatureProdPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(FeatureProdPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureProd A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureProd A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `product_id`, `feature_id`, `feature_av_id`, `by_default`, `position`, `created_at`, `updated_at` FROM `feature_prod` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new FeatureProd(); - $obj->hydrate($row); - FeatureProdPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return FeatureProd|FeatureProd[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|FeatureProd[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(FeatureProdPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(FeatureProdPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeatureProdPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeatureProdPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the feature_id column - * - * Example usage: - * - * $query->filterByFeatureId(1234); // WHERE feature_id = 1234 - * $query->filterByFeatureId(array(12, 34)); // WHERE feature_id IN (12, 34) - * $query->filterByFeatureId(array('min' => 12)); // WHERE feature_id >= 12 - * $query->filterByFeatureId(array('max' => 12)); // WHERE feature_id <= 12 - * - * - * @see filterByFeature() - * - * @param mixed $featureId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByFeatureId($featureId = null, $comparison = null) - { - if (is_array($featureId)) { - $useMinMax = false; - if (isset($featureId['min'])) { - $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($featureId['max'])) { - $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::FEATURE_ID, $featureId, $comparison); - } - - /** - * Filter the query on the feature_av_id column - * - * Example usage: - * - * $query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234 - * $query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34) - * $query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id >= 12 - * $query->filterByFeatureAvId(array('max' => 12)); // WHERE feature_av_id <= 12 - * - * - * @see filterByFeatureAv() - * - * @param mixed $featureAvId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByFeatureAvId($featureAvId = null, $comparison = null) - { - if (is_array($featureAvId)) { - $useMinMax = false; - if (isset($featureAvId['min'])) { - $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($featureAvId['max'])) { - $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAvId, $comparison); - } - - /** - * Filter the query on the by_default column - * - * Example usage: - * - * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue' - * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%' - * - * - * @param string $byDefault The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByByDefault($byDefault = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($byDefault)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $byDefault)) { - $byDefault = str_replace('*', '%', $byDefault); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FeatureProdPeer::BY_DEFAULT, $byDefault, $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 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(FeatureProdPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(FeatureProdPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureProdPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Feature object - * - * @param Feature|PropelObjectCollection $feature The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeature($feature, $comparison = null) - { - if ($feature instanceof Feature) { - return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->getId(), $comparison); - } elseif ($feature instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_ID, $feature->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeature() only accepts arguments of type Feature or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Feature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function joinFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Feature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Feature'); - } - - return $this; - } - - /** - * Use the Feature relation Feature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureQuery A secondary query class using the current class as primary query - */ - public function useFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Feature', '\Thelia\Model\FeatureQuery'); - } - - /** - * Filter the query by a related FeatureAv object - * - * @param FeatureAv|PropelObjectCollection $featureAv The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureProdQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureAv($featureAv, $comparison = null) - { - if ($featureAv instanceof FeatureAv) { - return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->getId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FeatureProdPeer::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function joinFeatureAv($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureAv'); - } - - return $this; - } - - /** - * Use the FeatureAv relation FeatureAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query - */ - public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFeatureAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); - } - - /** - * Exclude object from result - * - * @param FeatureProd $featureProd Object to remove from the list of results - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function prune($featureProd = null) - { - if ($featureProd) { - $this->addUsingAlias(FeatureProdPeer::ID, $featureProd->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(FeatureProdPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureProdPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureProdPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(FeatureProdPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(FeatureProdPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return FeatureProdQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(FeatureProdPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseFeatureQuery.php b/core/lib/Thelia/Model/om/BaseFeatureQuery.php deleted file mode 100755 index f9b008e05..000000000 --- a/core/lib/Thelia/Model/om/BaseFeatureQuery.php +++ /dev/null @@ -1,929 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Feature|Feature[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FeaturePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(FeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Feature A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Feature A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `visible`, `position`, `created_at`, `updated_at` FROM `feature` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Feature(); - $obj->hydrate($row); - FeaturePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Feature|Feature[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Feature[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(FeaturePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(FeaturePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FeaturePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeaturePeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 - * - * - * @param mixed $visible The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByVisible($visible = null, $comparison = null) - { - if (is_array($visible)) { - $useMinMax = false; - if (isset($visible['min'])) { - $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($visible['max'])) { - $this->addUsingAlias(FeaturePeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeaturePeer::VISIBLE, $visible, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(FeaturePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(FeaturePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeaturePeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeaturePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeaturePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related FeatureAv object - * - * @param FeatureAv|PropelObjectCollection $featureAv the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureAv($featureAv, $comparison = null) - { - if ($featureAv instanceof FeatureAv) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureAv->getFeatureId(), $comparison); - } elseif ($featureAv instanceof PropelObjectCollection) { - return $this - ->useFeatureAvQuery() - ->filterByPrimaryKeys($featureAv->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureAv() only accepts arguments of type FeatureAv or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureAv relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureAv($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureAv'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureAv'); - } - - return $this; - } - - /** - * Use the FeatureAv relation FeatureAv object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query - */ - public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureAv($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); - } - - /** - * Filter the query by a related FeatureProd object - * - * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureProd($featureProd, $comparison = null) - { - if ($featureProd instanceof FeatureProd) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureProd->getFeatureId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { - return $this - ->useFeatureProdQuery() - ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureProd relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureProd'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureProd'); - } - - return $this; - } - - /** - * Use the FeatureProd relation FeatureProd object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query - */ - public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureProd($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); - } - - /** - * Filter the query by a related FeatureCategory object - * - * @param FeatureCategory|PropelObjectCollection $featureCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureCategory($featureCategory, $comparison = null) - { - if ($featureCategory instanceof FeatureCategory) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureCategory->getFeatureId(), $comparison); - } elseif ($featureCategory instanceof PropelObjectCollection) { - return $this - ->useFeatureCategoryQuery() - ->filterByPrimaryKeys($featureCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureCategory() only accepts arguments of type FeatureCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureCategory'); - } - - return $this; - } - - /** - * Use the FeatureCategory relation FeatureCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureCategoryQuery A secondary query class using the current class as primary query - */ - public function useFeatureCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureCategory', '\Thelia\Model\FeatureCategoryQuery'); - } - - /** - * Filter the query by a related FeatureI18n object - * - * @param FeatureI18n|PropelObjectCollection $featureI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureI18n($featureI18n, $comparison = null) - { - if ($featureI18n instanceof FeatureI18n) { - return $this - ->addUsingAlias(FeaturePeer::ID, $featureI18n->getId(), $comparison); - } elseif ($featureI18n instanceof PropelObjectCollection) { - return $this - ->useFeatureI18nQuery() - ->filterByPrimaryKeys($featureI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureI18n() only accepts arguments of type FeatureI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinFeatureI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureI18n'); - } - - return $this; - } - - /** - * Use the FeatureI18n relation FeatureI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureI18nQuery A secondary query class using the current class as primary query - */ - public function useFeatureI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFeatureI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', '\Thelia\Model\FeatureI18nQuery'); - } - - /** - * Filter the query by a related Category object - * using the feature_category table as cross reference - * - * @param Category $category the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FeatureQuery The current query, for fluid interface - */ - public function filterByCategory($category, $comparison = Criteria::EQUAL) - { - return $this - ->useFeatureCategoryQuery() - ->filterByCategory($category, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Feature $feature Object to remove from the list of results - * - * @return FeatureQuery The current query, for fluid interface - */ - public function prune($feature = null) - { - if ($feature) { - $this->addUsingAlias(FeaturePeer::ID, $feature->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return FeatureQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(FeaturePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return FeatureQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(FeaturePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return FeatureQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(FeaturePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return FeatureQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(FeaturePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return FeatureQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(FeaturePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return FeatureQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(FeaturePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; - - return $this - ->joinFeatureI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('FeatureI18n'); - $this->with['FeatureI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FeatureI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureI18n', 'Thelia\Model\FeatureI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFolder.php b/core/lib/Thelia/Model/om/BaseFolder.php deleted file mode 100755 index e2fefbb8a..000000000 --- a/core/lib/Thelia/Model/om/BaseFolder.php +++ /dev/null @@ -1,4141 +0,0 @@ -version = 0; - } - - /** - * Initializes internal state of BaseFolder 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 Folder The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FolderPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [parent] column. - * - * @param int $v new value - * @return Folder The current object (for fluent API support) - */ - public function setParent($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->parent !== $v) { - $this->parent = $v; - $this->modifiedColumns[] = FolderPeer::PARENT; - } - - - return $this; - } // setParent() - - /** - * Set the value of [link] column. - * - * @param string $v new value - * @return Folder The current object (for fluent API support) - */ - public function setLink($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->link !== $v) { - $this->link = $v; - $this->modifiedColumns[] = FolderPeer::LINK; - } - - - return $this; - } // setLink() - - /** - * Set the value of [visible] column. - * - * @param int $v new value - * @return Folder The current object (for fluent API support) - */ - public function setVisible($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->visible !== $v) { - $this->visible = $v; - $this->modifiedColumns[] = FolderPeer::VISIBLE; - } - - - return $this; - } // setVisible() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Folder The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = FolderPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Folder The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = FolderPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Folder The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = FolderPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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. - * - * 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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 10; // 10 = FolderPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Folder object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = FolderPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collImages = null; - - $this->collDocuments = null; - - $this->collRewritings = null; - - $this->collContentFolders = null; - - $this->collFolderI18ns = null; - - $this->collFolderVersions = null; - - $this->collContents = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FolderQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - // 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 - if (!$this->isColumnModified(FolderPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(FolderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(FolderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - // versionable behavior - if (isset($createVersion)) { - $this->addVersion($con); - } - FolderPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->contentsScheduledForDeletion !== null) { - if (!$this->contentsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->contentsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - ContentFolderQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->contentsScheduledForDeletion = null; - } - - foreach ($this->getContents() as $content) { - if ($content->isModified()) { - $content->save($con); - } - } - } elseif ($this->collContents) { - foreach ($this->collContents as $content) { - if ($content->isModified()) { - $content->save($con); - } - } - } - - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - foreach ($this->imagesScheduledForDeletion as $image) { - // need to save related object because we set the relation to null - $image->save($con); - } - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - foreach ($this->rewritingsScheduledForDeletion as $rewriting) { - // need to save related object because we set the relation to null - $rewriting->save($con); - } - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->contentFoldersScheduledForDeletion !== null) { - if (!$this->contentFoldersScheduledForDeletion->isEmpty()) { - ContentFolderQuery::create() - ->filterByPrimaryKeys($this->contentFoldersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->contentFoldersScheduledForDeletion = null; - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->folderI18nsScheduledForDeletion !== null) { - if (!$this->folderI18nsScheduledForDeletion->isEmpty()) { - FolderI18nQuery::create() - ->filterByPrimaryKeys($this->folderI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->folderI18nsScheduledForDeletion = null; - } - } - - if ($this->collFolderI18ns !== null) { - foreach ($this->collFolderI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - 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() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = FolderPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . FolderPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(FolderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FolderPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; - } - if ($this->isColumnModified(FolderPeer::LINK)) { - $modifiedColumns[':p' . $index++] = '`link`'; - } - if ($this->isColumnModified(FolderPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; - } - if ($this->isColumnModified(FolderPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(FolderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(FolderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - 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)', - 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); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = FolderPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentFolders !== null) { - foreach ($this->collContentFolders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFolderI18ns !== null) { - foreach ($this->collFolderI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFolderVersions !== null) { - foreach ($this->collFolderVersions as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getParent(); - break; - case 2: - return $this->getLink(); - break; - case 3: - return $this->getVisible(); - break; - case 4: - return $this->getPosition(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - 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['Folder'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Folder'][$this->getPrimaryKey()] = true; - $keys = FolderPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getParent(), - $keys[2] => $this->getLink(), - $keys[3] => $this->getVisible(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - $keys[7] => $this->getVersion(), - $keys[8] => $this->getVersionCreatedAt(), - $keys[9] => $this->getVersionCreatedBy(), - ); - if ($includeForeignObjects) { - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collContentFolders) { - $result['ContentFolders'] = $this->collContentFolders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - 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; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = FolderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setParent($value); - break; - case 2: - $this->setLink($value); - break; - case 3: - $this->setVisible($value); - break; - case 4: - $this->setPosition($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - 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 = FolderPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setParent($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setLink($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setVisible($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - 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(FolderPeer::DATABASE_NAME); - - if ($this->isColumnModified(FolderPeer::ID)) $criteria->add(FolderPeer::ID, $this->id); - if ($this->isColumnModified(FolderPeer::PARENT)) $criteria->add(FolderPeer::PARENT, $this->parent); - if ($this->isColumnModified(FolderPeer::LINK)) $criteria->add(FolderPeer::LINK, $this->link); - if ($this->isColumnModified(FolderPeer::VISIBLE)) $criteria->add(FolderPeer::VISIBLE, $this->visible); - if ($this->isColumnModified(FolderPeer::POSITION)) $criteria->add(FolderPeer::POSITION, $this->position); - if ($this->isColumnModified(FolderPeer::CREATED_AT)) $criteria->add(FolderPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(FolderPeer::UPDATED_AT)) $criteria->add(FolderPeer::UPDATED_AT, $this->updated_at); - 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; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(FolderPeer::DATABASE_NAME); - $criteria->add(FolderPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Folder (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setParent($this->getParent()); - $copyObj->setLink($this->getLink()); - $copyObj->setVisible($this->getVisible()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - $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; - - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - - foreach ($this->getContentFolders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentFolder($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFolderI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFolderI18n($relObj->copy($deepCopy)); - } - } - - 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) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Folder Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return FolderPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FolderPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Image' == $relationName) { - $this->initImages(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('Rewriting' == $relationName) { - $this->initRewritings(); - } - if ('ContentFolder' == $relationName) { - $this->initContentFolders(); - } - if ('FolderI18n' == $relationName) { - $this->initFolderI18ns(); - } - if ('FolderVersion' == $relationName) { - $this->initFolderVersions(); - } - } - - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Folder The current object (for fluent API support) - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; - } - - /** - * reset is the collImages collection loaded partially - * - * @return void - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); - } - - /** - * Gets an array of Image objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Image[] List of Image objects - * @throws PropelException - */ - public function getImages($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ImageQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - return $collImages; - } - - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $images A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setImages(PropelCollection $images, PropelPDO $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setFolder(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. - * - * @param Image $l Image - * @return Folder The current object (for fluent API support) - */ - public function addImage(Image $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setFolder($this); - } - - /** - * @param Image $image The image object to remove. - * @return Folder The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Folder The current object (for fluent API support) - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setFolder(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Folder The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setFolder($this); - } - - /** - * @param Document $document The document object to remove. - * @return Folder The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Folder The current object (for fluent API support) - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; - } - - /** - * reset is the collRewritings collection loaded partially - * - * @return void - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); - } - - /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = RewritingQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - return $collRewritings; - } - - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $rewritings A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setFolder(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. - * - * @param Rewriting $l Rewriting - * @return Folder The current object (for fluent API support) - */ - public function addRewriting(Rewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setFolder($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Folder The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinProduct($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Product', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getRewritings($query, $con); - } - - /** - * Clears out the collContentFolders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Folder The current object (for fluent API support) - * @see addContentFolders() - */ - public function clearContentFolders() - { - $this->collContentFolders = null; // important to set this to null since that means it is uninitialized - $this->collContentFoldersPartial = null; - - return $this; - } - - /** - * reset is the collContentFolders collection loaded partially - * - * @return void - */ - public function resetPartialContentFolders($v = true) - { - $this->collContentFoldersPartial = $v; - } - - /** - * Initializes the collContentFolders collection. - * - * By default this just sets the collContentFolders collection to an empty array (like clearcollContentFolders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentFolders($overrideExisting = true) - { - if (null !== $this->collContentFolders && !$overrideExisting) { - return; - } - $this->collContentFolders = new PropelObjectCollection(); - $this->collContentFolders->setModel('ContentFolder'); - } - - /** - * Gets an array of ContentFolder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Folder is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - * @throws PropelException - */ - public function getContentFolders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - // return empty collection - $this->initContentFolders(); - } else { - $collContentFolders = ContentFolderQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentFoldersPartial && count($collContentFolders)) { - $this->initContentFolders(false); - - foreach($collContentFolders as $obj) { - if (false == $this->collContentFolders->contains($obj)) { - $this->collContentFolders->append($obj); - } - } - - $this->collContentFoldersPartial = true; - } - - $collContentFolders->getInternalIterator()->rewind(); - return $collContentFolders; - } - - if($partial && $this->collContentFolders) { - foreach($this->collContentFolders as $obj) { - if($obj->isNew()) { - $collContentFolders[] = $obj; - } - } - } - - $this->collContentFolders = $collContentFolders; - $this->collContentFoldersPartial = false; - } - } - - return $this->collContentFolders; - } - - /** - * Sets a collection of ContentFolder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentFolders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setContentFolders(PropelCollection $contentFolders, PropelPDO $con = null) - { - $contentFoldersToDelete = $this->getContentFolders(new Criteria(), $con)->diff($contentFolders); - - $this->contentFoldersScheduledForDeletion = unserialize(serialize($contentFoldersToDelete)); - - foreach ($contentFoldersToDelete as $contentFolderRemoved) { - $contentFolderRemoved->setFolder(null); - } - - $this->collContentFolders = null; - foreach ($contentFolders as $contentFolder) { - $this->addContentFolder($contentFolder); - } - - $this->collContentFolders = $contentFolders; - $this->collContentFoldersPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentFolder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentFolder objects. - * @throws PropelException - */ - public function countContentFolders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentFoldersPartial && !$this->isNew(); - if (null === $this->collContentFolders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentFolders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentFolders()); - } - $query = ContentFolderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collContentFolders); - } - - /** - * Method called to associate a ContentFolder object to this object - * through the ContentFolder foreign key attribute. - * - * @param ContentFolder $l ContentFolder - * @return Folder The current object (for fluent API support) - */ - public function addContentFolder(ContentFolder $l) - { - if ($this->collContentFolders === null) { - $this->initContentFolders(); - $this->collContentFoldersPartial = true; - } - if (!in_array($l, $this->collContentFolders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentFolder($l); - } - - return $this; - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to add. - */ - protected function doAddContentFolder($contentFolder) - { - $this->collContentFolders[]= $contentFolder; - $contentFolder->setFolder($this); - } - - /** - * @param ContentFolder $contentFolder The contentFolder object to remove. - * @return Folder The current object (for fluent API support) - */ - public function removeContentFolder($contentFolder) - { - if ($this->getContentFolders()->contains($contentFolder)) { - $this->collContentFolders->remove($this->collContentFolders->search($contentFolder)); - if (null === $this->contentFoldersScheduledForDeletion) { - $this->contentFoldersScheduledForDeletion = clone $this->collContentFolders; - $this->contentFoldersScheduledForDeletion->clear(); - } - $this->contentFoldersScheduledForDeletion[]= clone $contentFolder; - $contentFolder->setFolder(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Folder is new, it will return - * an empty collection; or if this Folder has previously - * been saved, it will retrieve related ContentFolders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Folder. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentFolder[] List of ContentFolder objects - */ - public function getContentFoldersJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentFolderQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getContentFolders($query, $con); - } - - /** - * Clears out the collFolderI18ns 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 Folder The current object (for fluent API support) - * @see addFolderI18ns() - */ - public function clearFolderI18ns() - { - $this->collFolderI18ns = null; // important to set this to null since that means it is uninitialized - $this->collFolderI18nsPartial = null; - - return $this; - } - - /** - * reset is the collFolderI18ns collection loaded partially - * - * @return void - */ - public function resetPartialFolderI18ns($v = true) - { - $this->collFolderI18nsPartial = $v; - } - - /** - * Initializes the collFolderI18ns collection. - * - * By default this just sets the collFolderI18ns collection to an empty array (like clearcollFolderI18ns()); - * 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 initFolderI18ns($overrideExisting = true) - { - if (null !== $this->collFolderI18ns && !$overrideExisting) { - return; - } - $this->collFolderI18ns = new PropelObjectCollection(); - $this->collFolderI18ns->setModel('FolderI18n'); - } - - /** - * Gets an array of FolderI18n 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|FolderI18n[] List of FolderI18n objects - * @throws PropelException - */ - public function getFolderI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFolderI18nsPartial && !$this->isNew(); - if (null === $this->collFolderI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFolderI18ns) { - // return empty collection - $this->initFolderI18ns(); - } else { - $collFolderI18ns = FolderI18nQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFolderI18nsPartial && count($collFolderI18ns)) { - $this->initFolderI18ns(false); - - foreach($collFolderI18ns as $obj) { - if (false == $this->collFolderI18ns->contains($obj)) { - $this->collFolderI18ns->append($obj); - } - } - - $this->collFolderI18nsPartial = true; - } - - $collFolderI18ns->getInternalIterator()->rewind(); - return $collFolderI18ns; - } - - if($partial && $this->collFolderI18ns) { - foreach($this->collFolderI18ns as $obj) { - if($obj->isNew()) { - $collFolderI18ns[] = $obj; - } - } - } - - $this->collFolderI18ns = $collFolderI18ns; - $this->collFolderI18nsPartial = false; - } - } - - return $this->collFolderI18ns; - } - - /** - * Sets a collection of FolderI18n 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 $folderI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setFolderI18ns(PropelCollection $folderI18ns, PropelPDO $con = null) - { - $folderI18nsToDelete = $this->getFolderI18ns(new Criteria(), $con)->diff($folderI18ns); - - $this->folderI18nsScheduledForDeletion = unserialize(serialize($folderI18nsToDelete)); - - foreach ($folderI18nsToDelete as $folderI18nRemoved) { - $folderI18nRemoved->setFolder(null); - } - - $this->collFolderI18ns = null; - foreach ($folderI18ns as $folderI18n) { - $this->addFolderI18n($folderI18n); - } - - $this->collFolderI18ns = $folderI18ns; - $this->collFolderI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related FolderI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FolderI18n objects. - * @throws PropelException - */ - public function countFolderI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFolderI18nsPartial && !$this->isNew(); - if (null === $this->collFolderI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFolderI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFolderI18ns()); - } - $query = FolderI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collFolderI18ns); - } - - /** - * Method called to associate a FolderI18n object to this object - * through the FolderI18n foreign key attribute. - * - * @param FolderI18n $l FolderI18n - * @return Folder The current object (for fluent API support) - */ - public function addFolderI18n(FolderI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collFolderI18ns === null) { - $this->initFolderI18ns(); - $this->collFolderI18nsPartial = true; - } - if (!in_array($l, $this->collFolderI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFolderI18n($l); - } - - return $this; - } - - /** - * @param FolderI18n $folderI18n The folderI18n object to add. - */ - protected function doAddFolderI18n($folderI18n) - { - $this->collFolderI18ns[]= $folderI18n; - $folderI18n->setFolder($this); - } - - /** - * @param FolderI18n $folderI18n The folderI18n object to remove. - * @return Folder The current object (for fluent API support) - */ - public function removeFolderI18n($folderI18n) - { - if ($this->getFolderI18ns()->contains($folderI18n)) { - $this->collFolderI18ns->remove($this->collFolderI18ns->search($folderI18n)); - if (null === $this->folderI18nsScheduledForDeletion) { - $this->folderI18nsScheduledForDeletion = clone $this->collFolderI18ns; - $this->folderI18nsScheduledForDeletion->clear(); - } - $this->folderI18nsScheduledForDeletion[]= clone $folderI18n; - $folderI18n->setFolder(null); - } - - return $this; - } - - /** - * 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 Folder The current object (for fluent API support) - * @see addFolderVersions() - */ - public function clearFolderVersions() - { - $this->collFolderVersions = null; // important to set this to null since that means it is uninitialized - $this->collFolderVersionsPartial = null; - - return $this; - } - - /** - * 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; - } - - $collFolderVersions->getInternalIterator()->rewind(); - 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 - * @return Folder The current object (for fluent API support) - */ - public function setFolderVersions(PropelCollection $folderVersions, PropelPDO $con = null) - { - $folderVersionsToDelete = $this->getFolderVersions(new Criteria(), $con)->diff($folderVersions); - - $this->folderVersionsScheduledForDeletion = unserialize(serialize($folderVersionsToDelete)); - - foreach ($folderVersionsToDelete as $folderVersionRemoved) { - $folderVersionRemoved->setFolder(null); - } - - $this->collFolderVersions = null; - foreach ($folderVersions as $folderVersion) { - $this->addFolderVersion($folderVersion); - } - - $this->collFolderVersions = $folderVersions; - $this->collFolderVersionsPartial = false; - - return $this; - } - - /** - * 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; - } - - if($partial && !$criteria) { - return count($this->getFolderVersions()); - } - $query = FolderVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - - return count($this->collFolderVersions); - } - - /** - * 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 (!in_array($l, $this->collFolderVersions->getArrayCopy(), true)) { // 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. - * @return Folder The current object (for fluent API support) - */ - 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[]= clone $folderVersion; - $folderVersion->setFolder(null); - } - - return $this; - } - - /** - * Clears out the collContents 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 Folder The current object (for fluent API support) - * @see addContents() - */ - public function clearContents() - { - $this->collContents = null; // important to set this to null since that means it is uninitialized - $this->collContentsPartial = null; - - return $this; - } - - /** - * Initializes the collContents collection. - * - * By default this just sets the collContents collection to an empty collection (like clearContents()); - * 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. - * - * @return void - */ - public function initContents() - { - $this->collContents = new PropelObjectCollection(); - $this->collContents->setModel('Content'); - } - - /** - * Gets a collection of Content objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Content[] List of Content objects - */ - public function getContents($criteria = null, PropelPDO $con = null) - { - if (null === $this->collContents || null !== $criteria) { - if ($this->isNew() && null === $this->collContents) { - // return empty collection - $this->initContents(); - } else { - $collContents = ContentQuery::create(null, $criteria) - ->filterByFolder($this) - ->find($con); - if (null !== $criteria) { - return $collContents; - } - $this->collContents = $collContents; - } - } - - return $this->collContents; - } - - /** - * Sets a collection of Content objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * 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 $contents A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Folder The current object (for fluent API support) - */ - public function setContents(PropelCollection $contents, PropelPDO $con = null) - { - $this->clearContents(); - $currentContents = $this->getContents(); - - $this->contentsScheduledForDeletion = $currentContents->diff($contents); - - foreach ($contents as $content) { - if (!$currentContents->contains($content)) { - $this->doAddContent($content); - } - } - - $this->collContents = $contents; - - return $this; - } - - /** - * Gets the number of Content objects related by a many-to-many relationship - * to the current object by way of the content_folder cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Content objects - */ - public function countContents($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collContents || null !== $criteria) { - if ($this->isNew() && null === $this->collContents) { - return 0; - } else { - $query = ContentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByFolder($this) - ->count($con); - } - } else { - return count($this->collContents); - } - } - - /** - * Associate a Content object to this object - * through the content_folder cross reference table. - * - * @param Content $content The ContentFolder object to relate - * @return Folder The current object (for fluent API support) - */ - public function addContent(Content $content) - { - if ($this->collContents === null) { - $this->initContents(); - } - if (!$this->collContents->contains($content)) { // only add it if the **same** object is not already associated - $this->doAddContent($content); - - $this->collContents[]= $content; - } - - return $this; - } - - /** - * @param Content $content The content object to add. - */ - protected function doAddContent($content) - { - $contentFolder = new ContentFolder(); - $contentFolder->setContent($content); - $this->addContentFolder($contentFolder); - } - - /** - * Remove a Content object to this object - * through the content_folder cross reference table. - * - * @param Content $content The ContentFolder object to relate - * @return Folder The current object (for fluent API support) - */ - public function removeContent(Content $content) - { - if ($this->getContents()->contains($content)) { - $this->collContents->remove($this->collContents->search($content)); - if (null === $this->contentsScheduledForDeletion) { - $this->contentsScheduledForDeletion = clone $this->collContents; - $this->contentsScheduledForDeletion->clear(); - } - $this->contentsScheduledForDeletion[]= $content; - } - - return $this; - } - - /** - * 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentFolders) { - foreach ($this->collContentFolders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFolderI18ns) { - foreach ($this->collFolderI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFolderVersions) { - foreach ($this->collFolderVersions as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContents) { - foreach ($this->collContents as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collRewritings instanceof PropelCollection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; - if ($this->collContentFolders instanceof PropelCollection) { - $this->collContentFolders->clearIterator(); - } - $this->collContentFolders = null; - if ($this->collFolderI18ns instanceof PropelCollection) { - $this->collFolderI18ns->clearIterator(); - } - $this->collFolderI18ns = null; - if ($this->collFolderVersions instanceof PropelCollection) { - $this->collFolderVersions->clearIterator(); - } - $this->collFolderVersions = null; - if ($this->collContents instanceof PropelCollection) { - $this->collContents->clearIterator(); - } - $this->collContents = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FolderPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Folder The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = FolderPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Folder The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return FolderI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collFolderI18ns) { - foreach ($this->collFolderI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new FolderI18n(); - $translation->setLocale($locale); - } else { - $translation = FolderI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addFolderI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Folder The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - FolderI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collFolderI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collFolderI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return FolderI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - 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/BaseFolderI18n.php b/core/lib/Thelia/Model/om/BaseFolderI18n.php deleted file mode 100755 index 0da44efde..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseFolderI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = FolderI18nPeer::ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = FolderI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = FolderI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = FolderI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = FolderI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return FolderI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = FolderI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = FolderI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating FolderI18n 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(FolderI18nPeer::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 = FolderI18nPeer::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(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = FolderI18nQuery::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(FolderI18nPeer::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); - FolderI18nPeer::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(FolderI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(FolderI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(FolderI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(FolderI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(FolderI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(FolderI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `folder_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $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 = FolderI18nPeer::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 = FolderI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['FolderI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['FolderI18n'][serialize($this->getPrimaryKey())] = true; - $keys = FolderI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - 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 = FolderI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = FolderI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(FolderI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(FolderI18nPeer::ID)) $criteria->add(FolderI18nPeer::ID, $this->id); - if ($this->isColumnModified(FolderI18nPeer::LOCALE)) $criteria->add(FolderI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(FolderI18nPeer::TITLE)) $criteria->add(FolderI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(FolderI18nPeer::DESCRIPTION)) $criteria->add(FolderI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(FolderI18nPeer::CHAPO)) $criteria->add(FolderI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(FolderI18nPeer::POSTSCRIPTUM)) $criteria->add(FolderI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(FolderI18nPeer::DATABASE_NAME); - $criteria->add(FolderI18nPeer::ID, $this->id); - $criteria->add(FolderI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 FolderI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 FolderI18n 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 FolderI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new FolderI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Folder object. - * - * @param Folder $v - * @return FolderI18n 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->addFolderI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Folder object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->addFolderI18ns($this); - */ - } - - return $this->aFolder; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aFolder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(FolderI18nPeer::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/BaseFolderI18nPeer.php b/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php deleted file mode 100755 index d533de0ce..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (FolderI18nPeer::ID, FolderI18nPeer::LOCALE, FolderI18nPeer::TITLE, FolderI18nPeer::DESCRIPTION, FolderI18nPeer::CHAPO, FolderI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FolderI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (FolderI18nPeer::ID => 0, FolderI18nPeer::LOCALE => 1, FolderI18nPeer::TITLE => 2, FolderI18nPeer::DESCRIPTION => 3, FolderI18nPeer::CHAPO => 4, FolderI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FolderI18nPeer::getFieldNames($toType); - $key = isset(FolderI18nPeer::$fieldKeys[$fromType][$name]) ? FolderI18nPeer::$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(FolderI18nPeer::$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, FolderI18nPeer::$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 FolderI18nPeer::$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. FolderI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FolderI18nPeer::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(FolderI18nPeer::ID); - $criteria->addSelectColumn(FolderI18nPeer::LOCALE); - $criteria->addSelectColumn(FolderI18nPeer::TITLE); - $criteria->addSelectColumn(FolderI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(FolderI18nPeer::CHAPO); - $criteria->addSelectColumn(FolderI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(FolderI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FolderI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FolderI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FolderI18nPeer::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 FolderI18n - * @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 = FolderI18nPeer::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 FolderI18nPeer::populateObjects(FolderI18nPeer::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 directly (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(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FolderI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FolderI18nPeer::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 FolderI18n $obj A FolderI18n 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->getLocale())); - } // if key === null - FolderI18nPeer::$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 FolderI18n 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 FolderI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 FolderI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FolderI18nPeer::$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 FolderI18n 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(FolderI18nPeer::$instances[$key])) { - return FolderI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FolderI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FolderI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to folder_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FolderI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FolderI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FolderI18nPeer::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; - FolderI18nPeer::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 (FolderI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FolderI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FolderI18nPeer::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 + FolderI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FolderI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FolderI18nPeer::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(FolderI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FolderI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FolderI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FolderI18nPeer::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 FolderI18n 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 FolderI18n 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(FolderI18nPeer::DATABASE_NAME); - } - - FolderI18nPeer::addSelectColumns($criteria); - $startcol = FolderI18nPeer::NUM_HYDRATE_COLUMNS; - FolderPeer::addSelectColumns($criteria); - - $criteria->addJoin(FolderI18nPeer::ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FolderI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FolderI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = FolderI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FolderI18nPeer::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 (FolderI18n) to $obj2 (Folder) - $obj2->addFolderI18n($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(FolderI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FolderI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(FolderI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(FolderI18nPeer::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 FolderI18n 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 FolderI18n 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(FolderI18nPeer::DATABASE_NAME); - } - - FolderI18nPeer::addSelectColumns($criteria); - $startcol2 = FolderI18nPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(FolderI18nPeer::ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = FolderI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = FolderI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = FolderI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - FolderI18nPeer::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 (FolderI18n) to the collection in $obj2 (Folder) - $obj2->addFolderI18n($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(FolderI18nPeer::DATABASE_NAME)->getTable(FolderI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFolderI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFolderI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FolderI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FolderI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a FolderI18n or Criteria object. - * - * @param mixed $values Criteria or FolderI18n 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(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from FolderI18n object - } - - - // Set the correct dbName - $criteria->setDbName(FolderI18nPeer::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 FolderI18n or Criteria object. - * - * @param mixed $values Criteria or FolderI18n 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(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FolderI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FolderI18nPeer::ID); - $value = $criteria->remove(FolderI18nPeer::ID); - if ($value) { - $selectCriteria->add(FolderI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FolderI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(FolderI18nPeer::LOCALE); - $value = $criteria->remove(FolderI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(FolderI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FolderI18nPeer::TABLE_NAME); - } - - } else { // $values is FolderI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FolderI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the folder_i18n 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(FolderI18nPeer::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(FolderI18nPeer::TABLE_NAME, $con, FolderI18nPeer::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). - FolderI18nPeer::clearInstancePool(); - FolderI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a FolderI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or FolderI18n 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(FolderI18nPeer::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. - FolderI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof FolderI18n) { // it's a model object - // invalidate the cache for this single object - FolderI18nPeer::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(FolderI18nPeer::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(FolderI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(FolderI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - FolderI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(FolderI18nPeer::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); - FolderI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given FolderI18n 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 FolderI18n $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(FolderI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FolderI18nPeer::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(FolderI18nPeer::DATABASE_NAME, FolderI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return FolderI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = FolderI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FolderI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(FolderI18nPeer::DATABASE_NAME); - $criteria->add(FolderI18nPeer::ID, $id); - $criteria->add(FolderI18nPeer::LOCALE, $locale); - $v = FolderI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseFolderI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseFolderI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php b/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php deleted file mode 100755 index 8f2109c60..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return FolderI18n|FolderI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FolderI18nPeer::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(FolderI18nPeer::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 FolderI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `folder_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 FolderI18n(); - $obj->hydrate($row); - FolderI18nPeer::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 FolderI18n|FolderI18n[]|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|FolderI18n[]|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 FolderI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(FolderI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(FolderI18nPeer::LOCALE, $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 FolderI18nQuery 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(FolderI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(FolderI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 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 FolderI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FolderI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FolderI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 FolderI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderI18nPeer::POSTSCRIPTUM, $postscriptum, $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 FolderI18nQuery 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(FolderI18nPeer::ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(FolderI18nPeer::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 FolderI18nQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Exclude object from result - * - * @param FolderI18n $folderI18n Object to remove from the list of results - * - * @return FolderI18nQuery The current query, for fluid interface - */ - public function prune($folderI18n = null) - { - if ($folderI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(FolderI18nPeer::ID), $folderI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(FolderI18nPeer::LOCALE), $folderI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFolderPeer.php b/core/lib/Thelia/Model/om/BaseFolderPeer.php deleted file mode 100755 index 66503f818..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderPeer.php +++ /dev/null @@ -1,881 +0,0 @@ - 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, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. FolderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Parent' => 1, 'Link' => 2, 'Visible' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, '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, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = FolderPeer::getFieldNames($toType); - $key = isset(FolderPeer::$fieldKeys[$fromType][$name]) ? FolderPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(FolderPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, FolderPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return FolderPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. FolderPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(FolderPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(FolderPeer::ID); - $criteria->addSelectColumn(FolderPeer::PARENT); - $criteria->addSelectColumn(FolderPeer::LINK); - $criteria->addSelectColumn(FolderPeer::VISIBLE); - $criteria->addSelectColumn(FolderPeer::POSITION); - $criteria->addSelectColumn(FolderPeer::CREATED_AT); - $criteria->addSelectColumn(FolderPeer::UPDATED_AT); - $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'); - $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(FolderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - FolderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(FolderPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Folder - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = FolderPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return FolderPeer::populateObjects(FolderPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - FolderPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(FolderPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Folder $obj A Folder object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - FolderPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Folder object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Folder) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Folder object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(FolderPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Folder Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(FolderPeer::$instances[$key])) { - return FolderPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FolderPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - FolderPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to folder - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in RewritingPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingPeer::clearInstancePool(); - // Invalidate objects in ContentFolderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentFolderPeer::clearInstancePool(); - // 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(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = FolderPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = FolderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = FolderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - FolderPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Folder object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = FolderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + FolderPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = FolderPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - FolderPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(FolderPeer::DATABASE_NAME)->getTable(FolderPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseFolderPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseFolderPeer::TABLE_NAME)) { - $dbMap->addTableObject(new FolderTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return FolderPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Folder or Criteria object. - * - * @param mixed $values Criteria or Folder object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Folder object - } - - if ($criteria->containsKey(FolderPeer::ID) && $criteria->keyContainsValue(FolderPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.FolderPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(FolderPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Folder or Criteria object. - * - * @param mixed $values Criteria or Folder object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(FolderPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(FolderPeer::ID); - $value = $criteria->remove(FolderPeer::ID); - if ($value) { - $selectCriteria->add(FolderPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(FolderPeer::TABLE_NAME); - } - - } else { // $values is Folder object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(FolderPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the folder table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(FolderPeer::TABLE_NAME, $con, FolderPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - FolderPeer::clearInstancePool(); - FolderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Folder or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Folder object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - FolderPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Folder) { // it's a model object - // invalidate the cache for this single object - FolderPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(FolderPeer::DATABASE_NAME); - $criteria->add(FolderPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - FolderPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(FolderPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - FolderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Folder object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Folder $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(FolderPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(FolderPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(FolderPeer::DATABASE_NAME, FolderPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Folder - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = FolderPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(FolderPeer::DATABASE_NAME); - $criteria->add(FolderPeer::ID, $pk); - - $v = FolderPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Folder[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(FolderPeer::DATABASE_NAME); - $criteria->add(FolderPeer::ID, $pks, Criteria::IN); - $objs = FolderPeer::doSelect($criteria, $con); - } - - return $objs; - } - - // 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. -// -BaseFolderPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseFolderQuery.php b/core/lib/Thelia/Model/om/BaseFolderQuery.php deleted file mode 100755 index 82fa87ec1..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderQuery.php +++ /dev/null @@ -1,1292 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Folder|Folder[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = FolderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(FolderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Folder A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Folder A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `parent`, `link`, `visible`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `folder` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Folder(); - $obj->hydrate($row); - FolderPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Folder|Folder[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Folder[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(FolderPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(FolderPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FolderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FolderPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 - * - * - * @param mixed $parent The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByParent($parent = null, $comparison = null) - { - if (is_array($parent)) { - $useMinMax = false; - if (isset($parent['min'])) { - $this->addUsingAlias(FolderPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($parent['max'])) { - $this->addUsingAlias(FolderPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::PARENT, $parent, $comparison); - } - - /** - * Filter the query on the link column - * - * Example usage: - * - * $query->filterByLink('fooValue'); // WHERE link = 'fooValue' - * $query->filterByLink('%fooValue%'); // WHERE link LIKE '%fooValue%' - * - * - * @param string $link The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByLink($link = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($link)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $link)) { - $link = str_replace('*', '%', $link); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(FolderPeer::LINK, $link, $comparison); - } - - /** - * Filter the query on the visible column - * - * Example usage: - * - * $query->filterByVisible(1234); // WHERE visible = 1234 - * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 - * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 - * - * - * @param mixed $visible The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByVisible($visible = null, $comparison = null) - { - if (is_array($visible)) { - $useMinMax = false; - if (isset($visible['min'])) { - $this->addUsingAlias(FolderPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($visible['max'])) { - $this->addUsingAlias(FolderPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::VISIBLE, $visible, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(FolderPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(FolderPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query 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 - * $query->filterByVersion(array('max' => 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 - * - * @param Image|PropelObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(FolderPeer::ID, $image->getFolderId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related Document object - * - * @param Document|PropelObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(FolderPeer::ID, $document->getFolderId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Filter the query by a related Rewriting object - * - * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof Rewriting) { - return $this - ->addUsingAlias(FolderPeer::ID, $rewriting->getFolderId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - - /** - * Filter the query by a related ContentFolder object - * - * @param ContentFolder|PropelObjectCollection $contentFolder the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentFolder($contentFolder, $comparison = null) - { - if ($contentFolder instanceof ContentFolder) { - return $this - ->addUsingAlias(FolderPeer::ID, $contentFolder->getFolderId(), $comparison); - } elseif ($contentFolder instanceof PropelObjectCollection) { - return $this - ->useContentFolderQuery() - ->filterByPrimaryKeys($contentFolder->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentFolder() only accepts arguments of type ContentFolder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentFolder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinContentFolder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentFolder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentFolder'); - } - - return $this; - } - - /** - * Use the ContentFolder relation ContentFolder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentFolderQuery A secondary query class using the current class as primary query - */ - public function useContentFolderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinContentFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentFolder', '\Thelia\Model\ContentFolderQuery'); - } - - /** - * Filter the query by a related FolderI18n object - * - * @param FolderI18n|PropelObjectCollection $folderI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return FolderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFolderI18n($folderI18n, $comparison = null) - { - if ($folderI18n instanceof FolderI18n) { - return $this - ->addUsingAlias(FolderPeer::ID, $folderI18n->getId(), $comparison); - } elseif ($folderI18n instanceof PropelObjectCollection) { - return $this - ->useFolderI18nQuery() - ->filterByPrimaryKeys($folderI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFolderI18n() only accepts arguments of type FolderI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FolderI18n 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 joinFolderI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FolderI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FolderI18n'); - } - - return $this; - } - - /** - * Use the FolderI18n relation FolderI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderI18nQuery A secondary query class using the current class as primary query - */ - public function useFolderI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinFolderI18n($relationAlias, $joinType) - ->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'); - } - - /** - * Filter the query by a related Content object - * using the content_folder table as cross reference - * - * @param Content $content 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 - */ - public function filterByContent($content, $comparison = Criteria::EQUAL) - { - return $this - ->useContentFolderQuery() - ->filterByContent($content, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Folder $folder Object to remove from the list of results - * - * @return FolderQuery The current query, for fluid interface - */ - public function prune($folder = null) - { - if ($folder) { - $this->addUsingAlias(FolderPeer::ID, $folder->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return FolderQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(FolderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return FolderQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(FolderPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return FolderQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(FolderPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return FolderQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(FolderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return FolderQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(FolderPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return FolderQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(FolderPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; - - return $this - ->joinFolderI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FolderQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('FolderI18n'); - $this->with['FolderI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return FolderI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FolderI18n', 'Thelia\Model\FolderI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseFolderVersion.php b/core/lib/Thelia/Model/om/BaseFolderVersion.php deleted file mode 100755 index c83e6a410..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderVersion.php +++ /dev/null @@ -1,1505 +0,0 @@ -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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - 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; - } - - $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. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // 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 deleted file mode 100755 index 45c3292e3..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderVersionPeer.php +++ /dev/null @@ -1,1036 +0,0 @@ - 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 directly (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($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (FolderVersionPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - 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($row = 0, $colnum = 0) - { - 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 deleted file mode 100755 index 1c16728b4..000000000 --- a/core/lib/Thelia/Model/om/BaseFolderVersionQuery.php +++ /dev/null @@ -1,763 +0,0 @@ -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 - * $query->filterById(array('max' => 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)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(FolderVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(FolderVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderVersionPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByParent(array('max' => 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 - * $query->filterByVisible(array('max' => 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 - * $query->filterByPosition(array('max' => 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 - * $query->filterByVersion(array('max' => 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)) { - $useMinMax = false; - if (isset($version['min'])) { - $this->addUsingAlias(FolderVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($version['max'])) { - $this->addUsingAlias(FolderVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FolderVersionPeer::VERSION, $version, $comparison); - } - - /** - * 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/BaseGroup.php b/core/lib/Thelia/Model/om/BaseGroup.php deleted file mode 100755 index 0f300ced6..000000000 --- a/core/lib/Thelia/Model/om/BaseGroup.php +++ /dev/null @@ -1,2926 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Group The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Group The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = GroupPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Group The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = GroupPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Group The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = GroupPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = GroupPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Group object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = GroupPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAdminGroups = null; - - $this->collGroupResources = null; - - $this->collGroupModules = null; - - $this->collGroupI18ns = null; - - $this->collAdmins = null; - $this->collResources = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = GroupQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->adminsScheduledForDeletion !== null) { - if (!$this->adminsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->adminsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - AdminGroupQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->adminsScheduledForDeletion = null; - } - - foreach ($this->getAdmins() as $admin) { - if ($admin->isModified()) { - $admin->save($con); - } - } - } elseif ($this->collAdmins) { - foreach ($this->collAdmins as $admin) { - if ($admin->isModified()) { - $admin->save($con); - } - } - } - - if ($this->resourcesScheduledForDeletion !== null) { - if (!$this->resourcesScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->resourcesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - GroupResourceQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->resourcesScheduledForDeletion = null; - } - - foreach ($this->getResources() as $resource) { - if ($resource->isModified()) { - $resource->save($con); - } - } - } elseif ($this->collResources) { - foreach ($this->collResources as $resource) { - if ($resource->isModified()) { - $resource->save($con); - } - } - } - - if ($this->adminGroupsScheduledForDeletion !== null) { - if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - AdminGroupQuery::create() - ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->adminGroupsScheduledForDeletion = null; - } - } - - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupResourcesScheduledForDeletion = null; - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupModulesScheduledForDeletion !== null) { - if (!$this->groupModulesScheduledForDeletion->isEmpty()) { - GroupModuleQuery::create() - ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupModulesScheduledForDeletion = null; - } - } - - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupI18nsScheduledForDeletion !== null) { - if (!$this->groupI18nsScheduledForDeletion->isEmpty()) { - GroupI18nQuery::create() - ->filterByPrimaryKeys($this->groupI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupI18nsScheduledForDeletion = null; - } - } - - if ($this->collGroupI18ns !== null) { - foreach ($this->collGroupI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(GroupPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(GroupPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(GroupPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `group` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = GroupPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collGroupI18ns !== null) { - foreach ($this->collGroupI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Group'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Group'][$this->getPrimaryKey()] = true; - $keys = GroupPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collAdminGroups) { - $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupResources) { - $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupI18ns) { - $result['GroupI18ns'] = $this->collGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = GroupPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - - if ($this->isColumnModified(GroupPeer::ID)) $criteria->add(GroupPeer::ID, $this->id); - if ($this->isColumnModified(GroupPeer::CODE)) $criteria->add(GroupPeer::CODE, $this->code); - if ($this->isColumnModified(GroupPeer::CREATED_AT)) $criteria->add(GroupPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupPeer::UPDATED_AT)) $criteria->add(GroupPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - $criteria->add(GroupPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Group (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getAdminGroups() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAdminGroup($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupResources() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupResource($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupModules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Group Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return GroupPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new GroupPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AdminGroup' == $relationName) { - $this->initAdminGroups(); - } - if ('GroupResource' == $relationName) { - $this->initGroupResources(); - } - if ('GroupModule' == $relationName) { - $this->initGroupModules(); - } - if ('GroupI18n' == $relationName) { - $this->initGroupI18ns(); - } - } - - /** - * Clears out the collAdminGroups collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Group The current object (for fluent API support) - * @see addAdminGroups() - */ - public function clearAdminGroups() - { - $this->collAdminGroups = null; // important to set this to null since that means it is uninitialized - $this->collAdminGroupsPartial = null; - - return $this; - } - - /** - * reset is the collAdminGroups collection loaded partially - * - * @return void - */ - public function resetPartialAdminGroups($v = true) - { - $this->collAdminGroupsPartial = $v; - } - - /** - * Initializes the collAdminGroups collection. - * - * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAdminGroups($overrideExisting = true) - { - if (null !== $this->collAdminGroups && !$overrideExisting) { - return; - } - $this->collAdminGroups = new PropelObjectCollection(); - $this->collAdminGroups->setModel('AdminGroup'); - } - - /** - * Gets an array of AdminGroup objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects - * @throws PropelException - */ - public function getAdminGroups($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - // return empty collection - $this->initAdminGroups(); - } else { - $collAdminGroups = AdminGroupQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); - - foreach($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); - } - } - - $this->collAdminGroupsPartial = true; - } - - $collAdminGroups->getInternalIterator()->rewind(); - return $collAdminGroups; - } - - if($partial && $this->collAdminGroups) { - foreach($this->collAdminGroups as $obj) { - if($obj->isNew()) { - $collAdminGroups[] = $obj; - } - } - } - - $this->collAdminGroups = $collAdminGroups; - $this->collAdminGroupsPartial = false; - } - } - - return $this->collAdminGroups; - } - - /** - * Sets a collection of AdminGroup objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $adminGroups A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setAdminGroups(PropelCollection $adminGroups, PropelPDO $con = null) - { - $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - - $this->adminGroupsScheduledForDeletion = unserialize(serialize($adminGroupsToDelete)); - - foreach ($adminGroupsToDelete as $adminGroupRemoved) { - $adminGroupRemoved->setGroup(null); - } - - $this->collAdminGroups = null; - foreach ($adminGroups as $adminGroup) { - $this->addAdminGroup($adminGroup); - } - - $this->collAdminGroups = $adminGroups; - $this->collAdminGroupsPartial = false; - - return $this; - } - - /** - * Returns the number of related AdminGroup objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related AdminGroup objects. - * @throws PropelException - */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAdminGroups()); - } - $query = AdminGroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collAdminGroups); - } - - /** - * Method called to associate a AdminGroup object to this object - * through the AdminGroup foreign key attribute. - * - * @param AdminGroup $l AdminGroup - * @return Group The current object (for fluent API support) - */ - public function addAdminGroup(AdminGroup $l) - { - if ($this->collAdminGroups === null) { - $this->initAdminGroups(); - $this->collAdminGroupsPartial = true; - } - if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAdminGroup($l); - } - - return $this; - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to add. - */ - protected function doAddAdminGroup($adminGroup) - { - $this->collAdminGroups[]= $adminGroup; - $adminGroup->setGroup($this); - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to remove. - * @return Group The current object (for fluent API support) - */ - public function removeAdminGroup($adminGroup) - { - if ($this->getAdminGroups()->contains($adminGroup)) { - $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup)); - if (null === $this->adminGroupsScheduledForDeletion) { - $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups; - $this->adminGroupsScheduledForDeletion->clear(); - } - $this->adminGroupsScheduledForDeletion[]= clone $adminGroup; - $adminGroup->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related AdminGroups from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|AdminGroup[] List of AdminGroup objects - */ - public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = AdminGroupQuery::create(null, $criteria); - $query->joinWith('Admin', $join_behavior); - - return $this->getAdminGroups($query, $con); - } - - /** - * Clears out the collGroupResources collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Group The current object (for fluent API support) - * @see addGroupResources() - */ - public function clearGroupResources() - { - $this->collGroupResources = null; // important to set this to null since that means it is uninitialized - $this->collGroupResourcesPartial = null; - - return $this; - } - - /** - * reset is the collGroupResources collection loaded partially - * - * @return void - */ - public function resetPartialGroupResources($v = true) - { - $this->collGroupResourcesPartial = $v; - } - - /** - * Initializes the collGroupResources collection. - * - * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupResources($overrideExisting = true) - { - if (null !== $this->collGroupResources && !$overrideExisting) { - return; - } - $this->collGroupResources = new PropelObjectCollection(); - $this->collGroupResources->setModel('GroupResource'); - } - - /** - * Gets an array of GroupResource objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - * @throws PropelException - */ - public function getGroupResources($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - // return empty collection - $this->initGroupResources(); - } else { - $collGroupResources = GroupResourceQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); - - foreach($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); - } - } - - $this->collGroupResourcesPartial = true; - } - - $collGroupResources->getInternalIterator()->rewind(); - return $collGroupResources; - } - - if($partial && $this->collGroupResources) { - foreach($this->collGroupResources as $obj) { - if($obj->isNew()) { - $collGroupResources[] = $obj; - } - } - } - - $this->collGroupResources = $collGroupResources; - $this->collGroupResourcesPartial = false; - } - } - - return $this->collGroupResources; - } - - /** - * Sets a collection of GroupResource objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $groupResources A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) - { - $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - - $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); - - foreach ($groupResourcesToDelete as $groupResourceRemoved) { - $groupResourceRemoved->setGroup(null); - } - - $this->collGroupResources = null; - foreach ($groupResources as $groupResource) { - $this->addGroupResource($groupResource); - } - - $this->collGroupResources = $groupResources; - $this->collGroupResourcesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupResource objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupResource objects. - * @throws PropelException - */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getGroupResources()); - } - $query = GroupResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupResources); - } - - /** - * Method called to associate a GroupResource object to this object - * through the GroupResource foreign key attribute. - * - * @param GroupResource $l GroupResource - * @return Group The current object (for fluent API support) - */ - public function addGroupResource(GroupResource $l) - { - if ($this->collGroupResources === null) { - $this->initGroupResources(); - $this->collGroupResourcesPartial = true; - } - if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupResource($l); - } - - return $this; - } - - /** - * @param GroupResource $groupResource The groupResource object to add. - */ - protected function doAddGroupResource($groupResource) - { - $this->collGroupResources[]= $groupResource; - $groupResource->setGroup($this); - } - - /** - * @param GroupResource $groupResource The groupResource object to remove. - * @return Group The current object (for fluent API support) - */ - public function removeGroupResource($groupResource) - { - if ($this->getGroupResources()->contains($groupResource)) { - $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); - if (null === $this->groupResourcesScheduledForDeletion) { - $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; - $this->groupResourcesScheduledForDeletion->clear(); - } - $this->groupResourcesScheduledForDeletion[]= clone $groupResource; - $groupResource->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related GroupResources from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - */ - public function getGroupResourcesJoinResource($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = GroupResourceQuery::create(null, $criteria); - $query->joinWith('Resource', $join_behavior); - - return $this->getGroupResources($query, $con); - } - - /** - * Clears out the collGroupModules collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Group The current object (for fluent API support) - * @see addGroupModules() - */ - public function clearGroupModules() - { - $this->collGroupModules = null; // important to set this to null since that means it is uninitialized - $this->collGroupModulesPartial = null; - - return $this; - } - - /** - * reset is the collGroupModules collection loaded partially - * - * @return void - */ - public function resetPartialGroupModules($v = true) - { - $this->collGroupModulesPartial = $v; - } - - /** - * Initializes the collGroupModules collection. - * - * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupModules($overrideExisting = true) - { - if (null !== $this->collGroupModules && !$overrideExisting) { - return; - } - $this->collGroupModules = new PropelObjectCollection(); - $this->collGroupModules->setModel('GroupModule'); - } - - /** - * Gets an array of GroupModule objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupModule[] List of GroupModule objects - * @throws PropelException - */ - public function getGroupModules($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - // return empty collection - $this->initGroupModules(); - } else { - $collGroupModules = GroupModuleQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); - - foreach($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); - } - } - - $this->collGroupModulesPartial = true; - } - - $collGroupModules->getInternalIterator()->rewind(); - return $collGroupModules; - } - - if($partial && $this->collGroupModules) { - foreach($this->collGroupModules as $obj) { - if($obj->isNew()) { - $collGroupModules[] = $obj; - } - } - } - - $this->collGroupModules = $collGroupModules; - $this->collGroupModulesPartial = false; - } - } - - return $this->collGroupModules; - } - - /** - * Sets a collection of GroupModule objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $groupModules A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) - { - $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - - $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); - - foreach ($groupModulesToDelete as $groupModuleRemoved) { - $groupModuleRemoved->setGroup(null); - } - - $this->collGroupModules = null; - foreach ($groupModules as $groupModule) { - $this->addGroupModule($groupModule); - } - - $this->collGroupModules = $groupModules; - $this->collGroupModulesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupModule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupModule objects. - * @throws PropelException - */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getGroupModules()); - } - $query = GroupModuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupModules); - } - - /** - * Method called to associate a GroupModule object to this object - * through the GroupModule foreign key attribute. - * - * @param GroupModule $l GroupModule - * @return Group The current object (for fluent API support) - */ - public function addGroupModule(GroupModule $l) - { - if ($this->collGroupModules === null) { - $this->initGroupModules(); - $this->collGroupModulesPartial = true; - } - if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupModule($l); - } - - return $this; - } - - /** - * @param GroupModule $groupModule The groupModule object to add. - */ - protected function doAddGroupModule($groupModule) - { - $this->collGroupModules[]= $groupModule; - $groupModule->setGroup($this); - } - - /** - * @param GroupModule $groupModule The groupModule object to remove. - * @return Group The current object (for fluent API support) - */ - public function removeGroupModule($groupModule) - { - if ($this->getGroupModules()->contains($groupModule)) { - $this->collGroupModules->remove($this->collGroupModules->search($groupModule)); - if (null === $this->groupModulesScheduledForDeletion) { - $this->groupModulesScheduledForDeletion = clone $this->collGroupModules; - $this->groupModulesScheduledForDeletion->clear(); - } - $this->groupModulesScheduledForDeletion[]= clone $groupModule; - $groupModule->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related GroupModules from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|GroupModule[] List of GroupModule objects - */ - public function getGroupModulesJoinModule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = GroupModuleQuery::create(null, $criteria); - $query->joinWith('Module', $join_behavior); - - return $this->getGroupModules($query, $con); - } - - /** - * Clears out the collGroupI18ns 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 Group The current object (for fluent API support) - * @see addGroupI18ns() - */ - public function clearGroupI18ns() - { - $this->collGroupI18ns = null; // important to set this to null since that means it is uninitialized - $this->collGroupI18nsPartial = null; - - return $this; - } - - /** - * reset is the collGroupI18ns collection loaded partially - * - * @return void - */ - public function resetPartialGroupI18ns($v = true) - { - $this->collGroupI18nsPartial = $v; - } - - /** - * Initializes the collGroupI18ns collection. - * - * By default this just sets the collGroupI18ns collection to an empty array (like clearcollGroupI18ns()); - * 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 initGroupI18ns($overrideExisting = true) - { - if (null !== $this->collGroupI18ns && !$overrideExisting) { - return; - } - $this->collGroupI18ns = new PropelObjectCollection(); - $this->collGroupI18ns->setModel('GroupI18n'); - } - - /** - * Gets an array of GroupI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupI18n[] List of GroupI18n objects - * @throws PropelException - */ - public function getGroupI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupI18nsPartial && !$this->isNew(); - if (null === $this->collGroupI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupI18ns) { - // return empty collection - $this->initGroupI18ns(); - } else { - $collGroupI18ns = GroupI18nQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupI18nsPartial && count($collGroupI18ns)) { - $this->initGroupI18ns(false); - - foreach($collGroupI18ns as $obj) { - if (false == $this->collGroupI18ns->contains($obj)) { - $this->collGroupI18ns->append($obj); - } - } - - $this->collGroupI18nsPartial = true; - } - - $collGroupI18ns->getInternalIterator()->rewind(); - return $collGroupI18ns; - } - - if($partial && $this->collGroupI18ns) { - foreach($this->collGroupI18ns as $obj) { - if($obj->isNew()) { - $collGroupI18ns[] = $obj; - } - } - } - - $this->collGroupI18ns = $collGroupI18ns; - $this->collGroupI18nsPartial = false; - } - } - - return $this->collGroupI18ns; - } - - /** - * Sets a collection of GroupI18n 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 $groupI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setGroupI18ns(PropelCollection $groupI18ns, PropelPDO $con = null) - { - $groupI18nsToDelete = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns); - - $this->groupI18nsScheduledForDeletion = unserialize(serialize($groupI18nsToDelete)); - - foreach ($groupI18nsToDelete as $groupI18nRemoved) { - $groupI18nRemoved->setGroup(null); - } - - $this->collGroupI18ns = null; - foreach ($groupI18ns as $groupI18n) { - $this->addGroupI18n($groupI18n); - } - - $this->collGroupI18ns = $groupI18ns; - $this->collGroupI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupI18n objects. - * @throws PropelException - */ - public function countGroupI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupI18nsPartial && !$this->isNew(); - if (null === $this->collGroupI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getGroupI18ns()); - } - $query = GroupI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupI18ns); - } - - /** - * Method called to associate a GroupI18n object to this object - * through the GroupI18n foreign key attribute. - * - * @param GroupI18n $l GroupI18n - * @return Group The current object (for fluent API support) - */ - public function addGroupI18n(GroupI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collGroupI18ns === null) { - $this->initGroupI18ns(); - $this->collGroupI18nsPartial = true; - } - if (!in_array($l, $this->collGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupI18n($l); - } - - return $this; - } - - /** - * @param GroupI18n $groupI18n The groupI18n object to add. - */ - protected function doAddGroupI18n($groupI18n) - { - $this->collGroupI18ns[]= $groupI18n; - $groupI18n->setGroup($this); - } - - /** - * @param GroupI18n $groupI18n The groupI18n object to remove. - * @return Group The current object (for fluent API support) - */ - public function removeGroupI18n($groupI18n) - { - if ($this->getGroupI18ns()->contains($groupI18n)) { - $this->collGroupI18ns->remove($this->collGroupI18ns->search($groupI18n)); - if (null === $this->groupI18nsScheduledForDeletion) { - $this->groupI18nsScheduledForDeletion = clone $this->collGroupI18ns; - $this->groupI18nsScheduledForDeletion->clear(); - } - $this->groupI18nsScheduledForDeletion[]= clone $groupI18n; - $groupI18n->setGroup(null); - } - - return $this; - } - - /** - * Clears out the collAdmins 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 Group The current object (for fluent API support) - * @see addAdmins() - */ - public function clearAdmins() - { - $this->collAdmins = null; // important to set this to null since that means it is uninitialized - $this->collAdminsPartial = null; - - return $this; - } - - /** - * Initializes the collAdmins collection. - * - * By default this just sets the collAdmins collection to an empty collection (like clearAdmins()); - * 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. - * - * @return void - */ - public function initAdmins() - { - $this->collAdmins = new PropelObjectCollection(); - $this->collAdmins->setModel('Admin'); - } - - /** - * Gets a collection of Admin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Admin[] List of Admin objects - */ - public function getAdmins($criteria = null, PropelPDO $con = null) - { - if (null === $this->collAdmins || null !== $criteria) { - if ($this->isNew() && null === $this->collAdmins) { - // return empty collection - $this->initAdmins(); - } else { - $collAdmins = AdminQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - return $collAdmins; - } - $this->collAdmins = $collAdmins; - } - } - - return $this->collAdmins; - } - - /** - * Sets a collection of Admin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * 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 $admins A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setAdmins(PropelCollection $admins, PropelPDO $con = null) - { - $this->clearAdmins(); - $currentAdmins = $this->getAdmins(); - - $this->adminsScheduledForDeletion = $currentAdmins->diff($admins); - - foreach ($admins as $admin) { - if (!$currentAdmins->contains($admin)) { - $this->doAddAdmin($admin); - } - } - - $this->collAdmins = $admins; - - return $this; - } - - /** - * Gets the number of Admin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Admin objects - */ - public function countAdmins($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collAdmins || null !== $criteria) { - if ($this->isNew() && null === $this->collAdmins) { - return 0; - } else { - $query = AdminQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - } else { - return count($this->collAdmins); - } - } - - /** - * Associate a Admin object to this object - * through the admin_group cross reference table. - * - * @param Admin $admin The AdminGroup object to relate - * @return Group The current object (for fluent API support) - */ - public function addAdmin(Admin $admin) - { - if ($this->collAdmins === null) { - $this->initAdmins(); - } - if (!$this->collAdmins->contains($admin)) { // only add it if the **same** object is not already associated - $this->doAddAdmin($admin); - - $this->collAdmins[]= $admin; - } - - return $this; - } - - /** - * @param Admin $admin The admin object to add. - */ - protected function doAddAdmin($admin) - { - $adminGroup = new AdminGroup(); - $adminGroup->setAdmin($admin); - $this->addAdminGroup($adminGroup); - } - - /** - * Remove a Admin object to this object - * through the admin_group cross reference table. - * - * @param Admin $admin The AdminGroup object to relate - * @return Group The current object (for fluent API support) - */ - public function removeAdmin(Admin $admin) - { - if ($this->getAdmins()->contains($admin)) { - $this->collAdmins->remove($this->collAdmins->search($admin)); - if (null === $this->adminsScheduledForDeletion) { - $this->adminsScheduledForDeletion = clone $this->collAdmins; - $this->adminsScheduledForDeletion->clear(); - } - $this->adminsScheduledForDeletion[]= $admin; - } - - return $this; - } - - /** - * Clears out the collResources 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 Group The current object (for fluent API support) - * @see addResources() - */ - public function clearResources() - { - $this->collResources = null; // important to set this to null since that means it is uninitialized - $this->collResourcesPartial = null; - - return $this; - } - - /** - * Initializes the collResources collection. - * - * By default this just sets the collResources collection to an empty collection (like clearResources()); - * 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. - * - * @return void - */ - public function initResources() - { - $this->collResources = new PropelObjectCollection(); - $this->collResources->setModel('Resource'); - } - - /** - * Gets a collection of Resource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Group is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Resource[] List of Resource objects - */ - public function getResources($criteria = null, PropelPDO $con = null) - { - if (null === $this->collResources || null !== $criteria) { - if ($this->isNew() && null === $this->collResources) { - // return empty collection - $this->initResources(); - } else { - $collResources = ResourceQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - return $collResources; - } - $this->collResources = $collResources; - } - } - - return $this->collResources; - } - - /** - * Sets a collection of Resource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * 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 $resources A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Group The current object (for fluent API support) - */ - public function setResources(PropelCollection $resources, PropelPDO $con = null) - { - $this->clearResources(); - $currentResources = $this->getResources(); - - $this->resourcesScheduledForDeletion = $currentResources->diff($resources); - - foreach ($resources as $resource) { - if (!$currentResources->contains($resource)) { - $this->doAddResource($resource); - } - } - - $this->collResources = $resources; - - return $this; - } - - /** - * Gets the number of Resource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Resource objects - */ - public function countResources($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collResources || null !== $criteria) { - if ($this->isNew() && null === $this->collResources) { - return 0; - } else { - $query = ResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - } else { - return count($this->collResources); - } - } - - /** - * Associate a Resource object to this object - * through the group_resource cross reference table. - * - * @param Resource $resource The GroupResource object to relate - * @return Group The current object (for fluent API support) - */ - public function addResource(Resource $resource) - { - if ($this->collResources === null) { - $this->initResources(); - } - if (!$this->collResources->contains($resource)) { // only add it if the **same** object is not already associated - $this->doAddResource($resource); - - $this->collResources[]= $resource; - } - - return $this; - } - - /** - * @param Resource $resource The resource object to add. - */ - protected function doAddResource($resource) - { - $groupResource = new GroupResource(); - $groupResource->setResource($resource); - $this->addGroupResource($groupResource); - } - - /** - * Remove a Resource object to this object - * through the group_resource cross reference table. - * - * @param Resource $resource The GroupResource object to relate - * @return Group The current object (for fluent API support) - */ - public function removeResource(Resource $resource) - { - if ($this->getResources()->contains($resource)) { - $this->collResources->remove($this->collResources->search($resource)); - if (null === $this->resourcesScheduledForDeletion) { - $this->resourcesScheduledForDeletion = clone $this->collResources; - $this->resourcesScheduledForDeletion->clear(); - } - $this->resourcesScheduledForDeletion[]= $resource; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collAdminGroups) { - foreach ($this->collAdminGroups as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupResources) { - foreach ($this->collGroupResources as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupI18ns) { - foreach ($this->collGroupI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAdmins) { - foreach ($this->collAdmins as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collResources) { - foreach ($this->collResources as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collAdminGroups instanceof PropelCollection) { - $this->collAdminGroups->clearIterator(); - } - $this->collAdminGroups = null; - if ($this->collGroupResources instanceof PropelCollection) { - $this->collGroupResources->clearIterator(); - } - $this->collGroupResources = null; - if ($this->collGroupModules instanceof PropelCollection) { - $this->collGroupModules->clearIterator(); - } - $this->collGroupModules = null; - if ($this->collGroupI18ns instanceof PropelCollection) { - $this->collGroupI18ns->clearIterator(); - } - $this->collGroupI18ns = null; - if ($this->collAdmins instanceof PropelCollection) { - $this->collAdmins->clearIterator(); - } - $this->collAdmins = null; - if ($this->collResources instanceof PropelCollection) { - $this->collResources->clearIterator(); - } - $this->collResources = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Group The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Group The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return GroupI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collGroupI18ns) { - foreach ($this->collGroupI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new GroupI18n(); - $translation->setLocale($locale); - } else { - $translation = GroupI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addGroupI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Group The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - GroupI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collGroupI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collGroupI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return GroupI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseGroupI18n.php b/core/lib/Thelia/Model/om/BaseGroupI18n.php deleted file mode 100755 index 0aa9c78b0..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseGroupI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupI18nPeer::ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = GroupI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = GroupI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = GroupI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = GroupI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return GroupI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = GroupI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = GroupI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating GroupI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aGroup !== null && $this->id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::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 = GroupI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = GroupI18nQuery::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(GroupI18nPeer::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); - GroupI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(GroupI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(GroupI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(GroupI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(GroupI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(GroupI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `group_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if (!$this->aGroup->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures()); - } - } - - - if (($retval = GroupI18nPeer::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 = GroupI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['GroupI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())] = true; - $keys = GroupI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = GroupI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(GroupI18nPeer::ID)) $criteria->add(GroupI18nPeer::ID, $this->id); - if ($this->isColumnModified(GroupI18nPeer::LOCALE)) $criteria->add(GroupI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(GroupI18nPeer::TITLE)) $criteria->add(GroupI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(GroupI18nPeer::DESCRIPTION)) $criteria->add(GroupI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(GroupI18nPeer::CHAPO)) $criteria->add(GroupI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(GroupI18nPeer::POSTSCRIPTUM)) $criteria->add(GroupI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(GroupI18nPeer::DATABASE_NAME); - $criteria->add(GroupI18nPeer::ID, $this->id); - $criteria->add(GroupI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 GroupI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 GroupI18n 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 GroupI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new GroupI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Group object. - * - * @param Group $v - * @return GroupI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(Group $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Group object, it will not be re-added. - if ($v !== null) { - $v->addGroupI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Group object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Group The associated Group object. - * @throws PropelException - */ - public function getGroup(PropelPDO $con = null, $doQuery = true) - { - if ($this->aGroup === null && ($this->id !== null) && $doQuery) { - $this->aGroup = GroupQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupI18ns($this); - */ - } - - return $this->aGroup; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aGroup instanceof Persistent) { - $this->aGroup->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aGroup = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupI18nPeer::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/BaseGroupI18nPeer.php b/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php deleted file mode 100755 index 56f5b8702..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (GroupI18nPeer::ID, GroupI18nPeer::LOCALE, GroupI18nPeer::TITLE, GroupI18nPeer::DESCRIPTION, GroupI18nPeer::CHAPO, GroupI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. GroupI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (GroupI18nPeer::ID => 0, GroupI18nPeer::LOCALE => 1, GroupI18nPeer::TITLE => 2, GroupI18nPeer::DESCRIPTION => 3, GroupI18nPeer::CHAPO => 4, GroupI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = GroupI18nPeer::getFieldNames($toType); - $key = isset(GroupI18nPeer::$fieldKeys[$fromType][$name]) ? GroupI18nPeer::$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(GroupI18nPeer::$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, GroupI18nPeer::$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 GroupI18nPeer::$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. GroupI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(GroupI18nPeer::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(GroupI18nPeer::ID); - $criteria->addSelectColumn(GroupI18nPeer::LOCALE); - $criteria->addSelectColumn(GroupI18nPeer::TITLE); - $criteria->addSelectColumn(GroupI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(GroupI18nPeer::CHAPO); - $criteria->addSelectColumn(GroupI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(GroupI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(GroupI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::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 GroupI18n - * @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 = GroupI18nPeer::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 GroupI18nPeer::populateObjects(GroupI18nPeer::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 directly (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(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - GroupI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(GroupI18nPeer::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 GroupI18n $obj A GroupI18n 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->getLocale())); - } // if key === null - GroupI18nPeer::$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 GroupI18n 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 GroupI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 GroupI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(GroupI18nPeer::$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 GroupI18n 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(GroupI18nPeer::$instances[$key])) { - return GroupI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (GroupI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - GroupI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to group_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = GroupI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = GroupI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = GroupI18nPeer::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; - GroupI18nPeer::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 (GroupI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = GroupI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = GroupI18nPeer::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 + GroupI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - GroupI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupI18nPeer::ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of GroupI18n objects pre-filled with their Group objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupI18nPeer::DATABASE_NAME); - } - - GroupI18nPeer::addSelectColumns($criteria); - $startcol = GroupI18nPeer::NUM_HYDRATE_COLUMNS; - GroupPeer::addSelectColumns($criteria); - - $criteria->addJoin(GroupI18nPeer::ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = GroupI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (GroupI18n) to $obj2 (Group) - $obj2->addGroupI18n($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(GroupI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupI18nPeer::ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of GroupI18n 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 GroupI18n 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(GroupI18nPeer::DATABASE_NAME); - } - - GroupI18nPeer::addSelectColumns($criteria); - $startcol2 = GroupI18nPeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupI18nPeer::ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (GroupI18n) to the collection in $obj2 (Group) - $obj2->addGroupI18n($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(GroupI18nPeer::DATABASE_NAME)->getTable(GroupI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseGroupI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseGroupI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new GroupI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return GroupI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a GroupI18n or Criteria object. - * - * @param mixed $values Criteria or GroupI18n 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(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from GroupI18n object - } - - - // Set the correct dbName - $criteria->setDbName(GroupI18nPeer::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 GroupI18n or Criteria object. - * - * @param mixed $values Criteria or GroupI18n 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(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(GroupI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(GroupI18nPeer::ID); - $value = $criteria->remove(GroupI18nPeer::ID); - if ($value) { - $selectCriteria->add(GroupI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(GroupI18nPeer::LOCALE); - $value = $criteria->remove(GroupI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(GroupI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupI18nPeer::TABLE_NAME); - } - - } else { // $values is GroupI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(GroupI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the group_i18n 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(GroupI18nPeer::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(GroupI18nPeer::TABLE_NAME, $con, GroupI18nPeer::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). - GroupI18nPeer::clearInstancePool(); - GroupI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a GroupI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupI18n 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(GroupI18nPeer::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. - GroupI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof GroupI18n) { // it's a model object - // invalidate the cache for this single object - GroupI18nPeer::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(GroupI18nPeer::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(GroupI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(GroupI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - GroupI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(GroupI18nPeer::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); - GroupI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given GroupI18n 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 GroupI18n $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(GroupI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(GroupI18nPeer::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(GroupI18nPeer::DATABASE_NAME, GroupI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return GroupI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = GroupI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(GroupI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(GroupI18nPeer::DATABASE_NAME); - $criteria->add(GroupI18nPeer::ID, $id); - $criteria->add(GroupI18nPeer::LOCALE, $locale); - $v = GroupI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseGroupI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseGroupI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php b/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php deleted file mode 100755 index f0d73813b..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return GroupI18n|GroupI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupI18nPeer::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(GroupI18nPeer::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 GroupI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `group_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 GroupI18n(); - $obj->hydrate($row); - GroupI18nPeer::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 GroupI18n|GroupI18n[]|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|GroupI18n[]|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 GroupI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(GroupI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(GroupI18nPeer::LOCALE, $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 GroupI18nQuery 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(GroupI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(GroupI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByGroup() - * - * @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 GroupI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 GroupI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Group object - * - * @param Group|PropelObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof Group) { - return $this - ->addUsingAlias(GroupI18nPeer::ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupI18nPeer::ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Exclude object from result - * - * @param GroupI18n $groupI18n Object to remove from the list of results - * - * @return GroupI18nQuery The current query, for fluid interface - */ - public function prune($groupI18n = null) - { - if ($groupI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(GroupI18nPeer::ID), $groupI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(GroupI18nPeer::LOCALE), $groupI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseGroupModule.php b/core/lib/Thelia/Model/om/BaseGroupModule.php deleted file mode 100755 index 747f025a2..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupModule.php +++ /dev/null @@ -1,1369 +0,0 @@ -access = 0; - } - - /** - * Initializes internal state of BaseGroupModule object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - return $this->group_id; - } - - /** - * Get the [module_id] column value. - * - * @return int - */ - public function getModuleId() - { - return $this->module_id; - } - - /** - * Get the [access] column value. - * - * @return int - */ - public function getAccess() - { - return $this->access; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return GroupModule The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupModulePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return GroupModule The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = GroupModulePeer::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [module_id] column. - * - * @param int $v new value - * @return GroupModule The current object (for fluent API support) - */ - public function setModuleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->module_id !== $v) { - $this->module_id = $v; - $this->modifiedColumns[] = GroupModulePeer::MODULE_ID; - } - - if ($this->aModule !== null && $this->aModule->getId() !== $v) { - $this->aModule = null; - } - - - return $this; - } // setModuleId() - - /** - * Set the value of [access] column. - * - * @param int $v new value - * @return GroupModule The current object (for fluent API support) - */ - public function setAccess($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->access !== $v) { - $this->access = $v; - $this->modifiedColumns[] = GroupModulePeer::ACCESS; - } - - - return $this; - } // setAccess() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return GroupModule The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = GroupModulePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return GroupModule The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = GroupModulePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->access !== 0) { - return false; - } - - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->module_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->access = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = GroupModulePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating GroupModule object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) { - $this->aModule = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = GroupModulePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aModule = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = GroupModuleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupModulePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupModulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupModulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupModulePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aModule !== null) { - if ($this->aModule->isModified() || $this->aModule->isNew()) { - $affectedRows += $this->aModule->save($con); - } - $this->setModule($this->aModule); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupModulePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupModulePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupModulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(GroupModulePeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`group_id`'; - } - if ($this->isColumnModified(GroupModulePeer::MODULE_ID)) { - $modifiedColumns[':p' . $index++] = '`module_id`'; - } - if ($this->isColumnModified(GroupModulePeer::ACCESS)) { - $modifiedColumns[':p' . $index++] = '`access`'; - } - if ($this->isColumnModified(GroupModulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(GroupModulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `group_module` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`group_id`': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case '`module_id`': - $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT); - break; - case '`access`': - $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if (!$this->aGroup->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures()); - } - } - - if ($this->aModule !== null) { - if (!$this->aModule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aModule->getValidationFailures()); - } - } - - - if (($retval = GroupModulePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getModuleId(); - break; - case 3: - return $this->getAccess(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()] = true; - $keys = GroupModulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getModuleId(), - $keys[3] => $this->getAccess(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aModule) { - $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setModuleId($value); - break; - case 3: - $this->setAccess($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = GroupModulePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setModuleId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupModulePeer::DATABASE_NAME); - - if ($this->isColumnModified(GroupModulePeer::ID)) $criteria->add(GroupModulePeer::ID, $this->id); - if ($this->isColumnModified(GroupModulePeer::GROUP_ID)) $criteria->add(GroupModulePeer::GROUP_ID, $this->group_id); - if ($this->isColumnModified(GroupModulePeer::MODULE_ID)) $criteria->add(GroupModulePeer::MODULE_ID, $this->module_id); - if ($this->isColumnModified(GroupModulePeer::ACCESS)) $criteria->add(GroupModulePeer::ACCESS, $this->access); - if ($this->isColumnModified(GroupModulePeer::CREATED_AT)) $criteria->add(GroupModulePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupModulePeer::UPDATED_AT)) $criteria->add(GroupModulePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupModulePeer::DATABASE_NAME); - $criteria->add(GroupModulePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of GroupModule (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setModuleId($this->getModuleId()); - $copyObj->setAccess($this->getAccess()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return GroupModule Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return GroupModulePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new GroupModulePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Group object. - * - * @param Group $v - * @return GroupModule The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(Group $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Group object, it will not be re-added. - if ($v !== null) { - $v->addGroupModule($this); - } - - - return $this; - } - - - /** - * Get the associated Group object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Group The associated Group object. - * @throws PropelException - */ - public function getGroup(PropelPDO $con = null, $doQuery = true) - { - if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { - $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupModules($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a Module object. - * - * @param Module $v - * @return GroupModule The current object (for fluent API support) - * @throws PropelException - */ - public function setModule(Module $v = null) - { - if ($v === null) { - $this->setModuleId(NULL); - } else { - $this->setModuleId($v->getId()); - } - - $this->aModule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Module object, it will not be re-added. - if ($v !== null) { - $v->addGroupModule($this); - } - - - return $this; - } - - - /** - * Get the associated Module object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Module The associated Module object. - * @throws PropelException - */ - public function getModule(PropelPDO $con = null, $doQuery = true) - { - if ($this->aModule === null && ($this->module_id !== null) && $doQuery) { - $this->aModule = ModuleQuery::create()->findPk($this->module_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aModule->addGroupModules($this); - */ - } - - return $this->aModule; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->module_id = null; - $this->access = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aGroup instanceof Persistent) { - $this->aGroup->clearAllReferences($deep); - } - if ($this->aModule instanceof Persistent) { - $this->aModule->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aGroup = null; - $this->aModule = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupModulePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return GroupModule The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupModulePeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php b/core/lib/Thelia/Model/om/BaseGroupModulePeer.php deleted file mode 100755 index 629d3bf83..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupModulePeer.php +++ /dev/null @@ -1,1428 +0,0 @@ - array ('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID, GroupModulePeer::GROUP_ID, GroupModulePeer::MODULE_ID, GroupModulePeer::ACCESS, GroupModulePeer::CREATED_AT, GroupModulePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. GroupModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (GroupModulePeer::ID => 0, GroupModulePeer::GROUP_ID => 1, GroupModulePeer::MODULE_ID => 2, GroupModulePeer::ACCESS => 3, GroupModulePeer::CREATED_AT => 4, GroupModulePeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = GroupModulePeer::getFieldNames($toType); - $key = isset(GroupModulePeer::$fieldKeys[$fromType][$name]) ? GroupModulePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupModulePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, GroupModulePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return GroupModulePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. GroupModulePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(GroupModulePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupModulePeer::ID); - $criteria->addSelectColumn(GroupModulePeer::GROUP_ID); - $criteria->addSelectColumn(GroupModulePeer::MODULE_ID); - $criteria->addSelectColumn(GroupModulePeer::ACCESS); - $criteria->addSelectColumn(GroupModulePeer::CREATED_AT); - $criteria->addSelectColumn(GroupModulePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.group_id'); - $criteria->addSelectColumn($alias . '.module_id'); - $criteria->addSelectColumn($alias . '.access'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return GroupModule - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = GroupModulePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return GroupModulePeer::populateObjects(GroupModulePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - GroupModulePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param GroupModule $obj A GroupModule object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - GroupModulePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A GroupModule object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof GroupModule) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupModule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(GroupModulePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return GroupModule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(GroupModulePeer::$instances[$key])) { - return GroupModulePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (GroupModulePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - GroupModulePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to group_module - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = GroupModulePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupModulePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (GroupModule object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = GroupModulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = GroupModulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + GroupModulePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupModulePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - GroupModulePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Module table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinModule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of GroupModule objects pre-filled with their Group objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupModule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - } - - GroupModulePeer::addSelectColumns($criteria); - $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS; - GroupPeer::addSelectColumns($criteria); - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = GroupModulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupModulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (GroupModule) to $obj2 (Group) - $obj2->addGroupModule($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of GroupModule objects pre-filled with their Module objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupModule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - } - - GroupModulePeer::addSelectColumns($criteria); - $startcol = GroupModulePeer::NUM_HYDRATE_COLUMNS; - ModulePeer::addSelectColumns($criteria); - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = GroupModulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupModulePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ModulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ModulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ModulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (GroupModule) to $obj2 (Module) - $obj2->addGroupModule($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of GroupModule objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupModule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - } - - GroupModulePeer::addSelectColumns($criteria); - $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - ModulePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ModulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupModulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupModulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (GroupModule) to the collection in $obj2 (Group) - $obj2->addGroupModule($obj1); - } // if joined row not null - - // Add objects for joined Module rows - - $key3 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ModulePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ModulePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ModulePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (GroupModule) to the collection in $obj3 (Module) - $obj3->addGroupModule($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Module table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptModule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of GroupModule objects pre-filled with all related objects except Group. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupModule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - } - - GroupModulePeer::addSelectColumns($criteria); - $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS; - - ModulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ModulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupModulePeer::MODULE_ID, ModulePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupModulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupModulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Module rows - - $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ModulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ModulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ModulePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (GroupModule) to the collection in $obj2 (Module) - $obj2->addGroupModule($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of GroupModule objects pre-filled with all related objects except Module. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupModule objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - } - - GroupModulePeer::addSelectColumns($criteria); - $startcol2 = GroupModulePeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupModulePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupModulePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupModulePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupModulePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (GroupModule) to the collection in $obj2 (Group) - $obj2->addGroupModule($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME)->getTable(GroupModulePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseGroupModulePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseGroupModulePeer::TABLE_NAME)) { - $dbMap->addTableObject(new GroupModuleTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return GroupModulePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a GroupModule or Criteria object. - * - * @param mixed $values Criteria or GroupModule object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from GroupModule object - } - - if ($criteria->containsKey(GroupModulePeer::ID) && $criteria->keyContainsValue(GroupModulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModulePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a GroupModule or Criteria object. - * - * @param mixed $values Criteria or GroupModule object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(GroupModulePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(GroupModulePeer::ID); - $value = $criteria->remove(GroupModulePeer::ID); - if ($value) { - $selectCriteria->add(GroupModulePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupModulePeer::TABLE_NAME); - } - - } else { // $values is GroupModule object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the group_module table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(GroupModulePeer::TABLE_NAME, $con, GroupModulePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupModulePeer::clearInstancePool(); - GroupModulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a GroupModule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupModule object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - GroupModulePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof GroupModule) { // it's a model object - // invalidate the cache for this single object - GroupModulePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupModulePeer::DATABASE_NAME); - $criteria->add(GroupModulePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - GroupModulePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(GroupModulePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - GroupModulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given GroupModule object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param GroupModule $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(GroupModulePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(GroupModulePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(GroupModulePeer::DATABASE_NAME, GroupModulePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return GroupModule - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = GroupModulePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(GroupModulePeer::DATABASE_NAME); - $criteria->add(GroupModulePeer::ID, $pk); - - $v = GroupModulePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return GroupModule[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(GroupModulePeer::DATABASE_NAME); - $criteria->add(GroupModulePeer::ID, $pks, Criteria::IN); - $objs = GroupModulePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseGroupModulePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseGroupModulePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php b/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php deleted file mode 100755 index 4a0b7b0d1..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupModuleQuery.php +++ /dev/null @@ -1,750 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupModulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(GroupModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return GroupModule A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return GroupModule A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `group_id`, `module_id`, `access`, `created_at`, `updated_at` FROM `group_module` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new GroupModule(); - $obj->hydrate($row); - GroupModulePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return GroupModule|GroupModule[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|GroupModule[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(GroupModulePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(GroupModulePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupModulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 - * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the module_id column - * - * Example usage: - * - * $query->filterByModuleId(1234); // WHERE module_id = 1234 - * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34) - * $query->filterByModuleId(array('min' => 12)); // WHERE module_id >= 12 - * $query->filterByModuleId(array('max' => 12)); // WHERE module_id <= 12 - * - * - * @see filterByModule() - * - * @param mixed $moduleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByModuleId($moduleId = null, $comparison = null) - { - if (is_array($moduleId)) { - $useMinMax = false; - if (isset($moduleId['min'])) { - $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($moduleId['max'])) { - $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::MODULE_ID, $moduleId, $comparison); - } - - /** - * Filter the query on the access column - * - * Example usage: - * - * $query->filterByAccess(1234); // WHERE access = 1234 - * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) - * $query->filterByAccess(array('min' => 12)); // WHERE access >= 12 - * $query->filterByAccess(array('max' => 12)); // WHERE access <= 12 - * - * - * @param mixed $access The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByAccess($access = null, $comparison = null) - { - if (is_array($access)) { - $useMinMax = false; - if (isset($access['min'])) { - $this->addUsingAlias(GroupModulePeer::ACCESS, $access['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($access['max'])) { - $this->addUsingAlias(GroupModulePeer::ACCESS, $access['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::ACCESS, $access, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModulePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Group object - * - * @param Group|PropelObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof Group) { - return $this - ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupModulePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related Module object - * - * @param Module|PropelObjectCollection $module The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByModule($module, $comparison = null) - { - if ($module instanceof Module) { - return $this - ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->getId(), $comparison); - } elseif ($module instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupModulePeer::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Module relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Module'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Module'); - } - - return $this; - } - - /** - * Use the Module relation Module object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query - */ - public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); - } - - /** - * Exclude object from result - * - * @param GroupModule $groupModule Object to remove from the list of results - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function prune($groupModule = null) - { - if ($groupModule) { - $this->addUsingAlias(GroupModulePeer::ID, $groupModule->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupModulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupModulePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupModulePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupModulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupModulePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return GroupModuleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupModulePeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseGroupPeer.php b/core/lib/Thelia/Model/om/BaseGroupPeer.php deleted file mode 100755 index 1a1a18f1e..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupPeer.php +++ /dev/null @@ -1,808 +0,0 @@ - array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (GroupPeer::ID, GroupPeer::CODE, GroupPeer::CREATED_AT, GroupPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. GroupPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (GroupPeer::ID => 0, GroupPeer::CODE => 1, GroupPeer::CREATED_AT => 2, GroupPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = GroupPeer::getFieldNames($toType); - $key = isset(GroupPeer::$fieldKeys[$fromType][$name]) ? GroupPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, GroupPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return GroupPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. GroupPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(GroupPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupPeer::ID); - $criteria->addSelectColumn(GroupPeer::CODE); - $criteria->addSelectColumn(GroupPeer::CREATED_AT); - $criteria->addSelectColumn(GroupPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(GroupPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Group - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = GroupPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return GroupPeer::populateObjects(GroupPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - GroupPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(GroupPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Group $obj A Group object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - GroupPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Group object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Group) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Group object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(GroupPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Group Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(GroupPeer::$instances[$key])) { - return GroupPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (GroupPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - GroupPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to group - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in AdminGroupPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AdminGroupPeer::clearInstancePool(); - // Invalidate objects in GroupResourcePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupResourcePeer::clearInstancePool(); - // Invalidate objects in GroupModulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupModulePeer::clearInstancePool(); - // Invalidate objects in GroupI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = GroupPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = GroupPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = GroupPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Group object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = GroupPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + GroupPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - GroupPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(GroupPeer::DATABASE_NAME)->getTable(GroupPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseGroupPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseGroupPeer::TABLE_NAME)) { - $dbMap->addTableObject(new GroupTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return GroupPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Group or Criteria object. - * - * @param mixed $values Criteria or Group object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Group object - } - - if ($criteria->containsKey(GroupPeer::ID) && $criteria->keyContainsValue(GroupPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(GroupPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Group or Criteria object. - * - * @param mixed $values Criteria or Group object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(GroupPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(GroupPeer::ID); - $value = $criteria->remove(GroupPeer::ID); - if ($value) { - $selectCriteria->add(GroupPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupPeer::TABLE_NAME); - } - - } else { // $values is Group object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(GroupPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the group table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(GroupPeer::TABLE_NAME, $con, GroupPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupPeer::clearInstancePool(); - GroupPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Group or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Group object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - GroupPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Group) { // it's a model object - // invalidate the cache for this single object - GroupPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - $criteria->add(GroupPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - GroupPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(GroupPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - GroupPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Group object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Group $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(GroupPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(GroupPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(GroupPeer::DATABASE_NAME, GroupPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Group - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = GroupPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - $criteria->add(GroupPeer::ID, $pk); - - $v = GroupPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Group[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(GroupPeer::DATABASE_NAME); - $criteria->add(GroupPeer::ID, $pks, Criteria::IN); - $objs = GroupPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseGroupPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseGroupPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseGroupQuery.php b/core/lib/Thelia/Model/om/BaseGroupQuery.php deleted file mode 100755 index 5c9695e10..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupQuery.php +++ /dev/null @@ -1,888 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Group|Group[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(GroupPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Group A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Group A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `group` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Group(); - $obj->hydrate($row); - GroupPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Group|Group[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Group[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(GroupPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(GroupPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related AdminGroup object - * - * @param AdminGroup|PropelObjectCollection $adminGroup the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAdminGroup($adminGroup, $comparison = null) - { - if ($adminGroup instanceof AdminGroup) { - return $this - ->addUsingAlias(GroupPeer::ID, $adminGroup->getGroupId(), $comparison); - } elseif ($adminGroup instanceof PropelObjectCollection) { - return $this - ->useAdminGroupQuery() - ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type AdminGroup or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AdminGroup relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AdminGroup'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AdminGroup'); - } - - return $this; - } - - /** - * Use the AdminGroup relation AdminGroup object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query - */ - public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAdminGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); - } - - /** - * Filter the query by a related GroupResource object - * - * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroupResource($groupResource, $comparison = null) - { - if ($groupResource instanceof GroupResource) { - return $this - ->addUsingAlias(GroupPeer::ID, $groupResource->getGroupId(), $comparison); - } elseif ($groupResource instanceof PropelObjectCollection) { - return $this - ->useGroupResourceQuery() - ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupResource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupResource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupResource'); - } - - return $this; - } - - /** - * Use the GroupResource relation GroupResource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query - */ - public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); - } - - /** - * Filter the query by a related GroupModule object - * - * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroupModule($groupModule, $comparison = null) - { - if ($groupModule instanceof GroupModule) { - return $this - ->addUsingAlias(GroupPeer::ID, $groupModule->getGroupId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { - return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupModule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupModule'); - } - - return $this; - } - - /** - * Use the GroupModule relation GroupModule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query - */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); - } - - /** - * Filter the query by a related GroupI18n object - * - * @param GroupI18n|PropelObjectCollection $groupI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroupI18n($groupI18n, $comparison = null) - { - if ($groupI18n instanceof GroupI18n) { - return $this - ->addUsingAlias(GroupPeer::ID, $groupI18n->getId(), $comparison); - } elseif ($groupI18n instanceof PropelObjectCollection) { - return $this - ->useGroupI18nQuery() - ->filterByPrimaryKeys($groupI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupI18n() only accepts arguments of type GroupI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinGroupI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupI18n'); - } - - return $this; - } - - /** - * Use the GroupI18n relation GroupI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupI18nQuery A secondary query class using the current class as primary query - */ - public function useGroupI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinGroupI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery'); - } - - /** - * Filter the query by a related Admin object - * using the admin_group table as cross reference - * - * @param Admin $admin the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByAdmin($admin, $comparison = Criteria::EQUAL) - { - return $this - ->useAdminGroupQuery() - ->filterByAdmin($admin, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Resource object - * using the group_resource table as cross reference - * - * @param Resource $resource the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupQuery The current query, for fluid interface - */ - public function filterByResource($resource, $comparison = Criteria::EQUAL) - { - return $this - ->useGroupResourceQuery() - ->filterByResource($resource, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Group $group Object to remove from the list of results - * - * @return GroupQuery The current query, for fluid interface - */ - public function prune($group = null) - { - if ($group) { - $this->addUsingAlias(GroupPeer::ID, $group->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return GroupQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return GroupQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return GroupQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return GroupQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return GroupQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return GroupQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; - - return $this - ->joinGroupI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return GroupQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('GroupI18n'); - $this->with['GroupI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return GroupI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', 'Thelia\Model\GroupI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseGroupResource.php b/core/lib/Thelia/Model/om/BaseGroupResource.php deleted file mode 100755 index 589b76550..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupResource.php +++ /dev/null @@ -1,1440 +0,0 @@ -read = 0; - $this->write = 0; - } - - /** - * Initializes internal state of BaseGroupResource object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - return $this->group_id; - } - - /** - * Get the [resource_id] column value. - * - * @return int - */ - public function getResourceId() - { - return $this->resource_id; - } - - /** - * Get the [read] column value. - * - * @return int - */ - public function getRead() - { - return $this->read; - } - - /** - * Get the [write] column value. - * - * @return int - */ - public function getWrite() - { - return $this->write; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return GroupResource The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupResourcePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return GroupResource The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = GroupResourcePeer::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [resource_id] column. - * - * @param int $v new value - * @return GroupResource The current object (for fluent API support) - */ - public function setResourceId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->resource_id !== $v) { - $this->resource_id = $v; - $this->modifiedColumns[] = GroupResourcePeer::RESOURCE_ID; - } - - if ($this->aResource !== null && $this->aResource->getId() !== $v) { - $this->aResource = null; - } - - - return $this; - } // setResourceId() - - /** - * Set the value of [read] column. - * - * @param int $v new value - * @return GroupResource The current object (for fluent API support) - */ - public function setRead($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->read !== $v) { - $this->read = $v; - $this->modifiedColumns[] = GroupResourcePeer::READ; - } - - - return $this; - } // setRead() - - /** - * Set the value of [write] column. - * - * @param int $v new value - * @return GroupResource The current object (for fluent API support) - */ - public function setWrite($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->write !== $v) { - $this->write = $v; - $this->modifiedColumns[] = GroupResourcePeer::WRITE; - } - - - return $this; - } // setWrite() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return GroupResource The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = GroupResourcePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return GroupResource The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = GroupResourcePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->read !== 0) { - return false; - } - - if ($this->write !== 0) { - return false; - } - - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->group_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->resource_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->read = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->write = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = GroupResourcePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating GroupResource object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) { - $this->aResource = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = GroupResourcePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aResource = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = GroupResourceQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupResourcePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupResourcePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aResource !== null) { - if ($this->aResource->isModified() || $this->aResource->isNew()) { - $affectedRows += $this->aResource->save($con); - } - $this->setResource($this->aResource); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupResourcePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupResourcePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupResourcePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(GroupResourcePeer::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = '`group_id`'; - } - if ($this->isColumnModified(GroupResourcePeer::RESOURCE_ID)) { - $modifiedColumns[':p' . $index++] = '`resource_id`'; - } - if ($this->isColumnModified(GroupResourcePeer::READ)) { - $modifiedColumns[':p' . $index++] = '`read`'; - } - if ($this->isColumnModified(GroupResourcePeer::WRITE)) { - $modifiedColumns[':p' . $index++] = '`write`'; - } - if ($this->isColumnModified(GroupResourcePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(GroupResourcePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `group_resource` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`group_id`': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case '`resource_id`': - $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); - break; - case '`read`': - $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); - break; - case '`write`': - $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if (!$this->aGroup->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aGroup->getValidationFailures()); - } - } - - if ($this->aResource !== null) { - if (!$this->aResource->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aResource->getValidationFailures()); - } - } - - - if (($retval = GroupResourcePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getResourceId(); - break; - case 3: - return $this->getRead(); - break; - case 4: - return $this->getWrite(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())] = true; - $keys = GroupResourcePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getResourceId(), - $keys[3] => $this->getRead(), - $keys[4] => $this->getWrite(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aResource) { - $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = GroupResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setResourceId($value); - break; - case 3: - $this->setRead($value); - break; - case 4: - $this->setWrite($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = GroupResourcePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME); - - if ($this->isColumnModified(GroupResourcePeer::ID)) $criteria->add(GroupResourcePeer::ID, $this->id); - if ($this->isColumnModified(GroupResourcePeer::GROUP_ID)) $criteria->add(GroupResourcePeer::GROUP_ID, $this->group_id); - if ($this->isColumnModified(GroupResourcePeer::RESOURCE_ID)) $criteria->add(GroupResourcePeer::RESOURCE_ID, $this->resource_id); - if ($this->isColumnModified(GroupResourcePeer::READ)) $criteria->add(GroupResourcePeer::READ, $this->read); - if ($this->isColumnModified(GroupResourcePeer::WRITE)) $criteria->add(GroupResourcePeer::WRITE, $this->write); - if ($this->isColumnModified(GroupResourcePeer::CREATED_AT)) $criteria->add(GroupResourcePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupResourcePeer::UPDATED_AT)) $criteria->add(GroupResourcePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME); - $criteria->add(GroupResourcePeer::ID, $this->id); - $criteria->add(GroupResourcePeer::GROUP_ID, $this->group_id); - $criteria->add(GroupResourcePeer::RESOURCE_ID, $this->resource_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getGroupId(); - $pks[2] = $this->getResourceId(); - - 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->setGroupId($keys[1]); - $this->setResourceId($keys[2]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getResourceId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of GroupResource (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setResourceId($this->getResourceId()); - $copyObj->setRead($this->getRead()); - $copyObj->setWrite($this->getWrite()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return GroupResource Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return GroupResourcePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new GroupResourcePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Group object. - * - * @param Group $v - * @return GroupResource The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(Group $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Group object, it will not be re-added. - if ($v !== null) { - $v->addGroupResource($this); - } - - - return $this; - } - - - /** - * Get the associated Group object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Group The associated Group object. - * @throws PropelException - */ - public function getGroup(PropelPDO $con = null, $doQuery = true) - { - if ($this->aGroup === null && ($this->group_id !== null) && $doQuery) { - $this->aGroup = GroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupResources($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a Resource object. - * - * @param Resource $v - * @return GroupResource The current object (for fluent API support) - * @throws PropelException - */ - public function setResource(Resource $v = null) - { - if ($v === null) { - $this->setResourceId(NULL); - } else { - $this->setResourceId($v->getId()); - } - - $this->aResource = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Resource object, it will not be re-added. - if ($v !== null) { - $v->addGroupResource($this); - } - - - return $this; - } - - - /** - * Get the associated Resource object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Resource The associated Resource object. - * @throws PropelException - */ - public function getResource(PropelPDO $con = null, $doQuery = true) - { - if ($this->aResource === null && ($this->resource_id !== null) && $doQuery) { - $this->aResource = ResourceQuery::create()->findPk($this->resource_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aResource->addGroupResources($this); - */ - } - - return $this->aResource; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->resource_id = null; - $this->read = null; - $this->write = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aGroup instanceof Persistent) { - $this->aGroup->clearAllReferences($deep); - } - if ($this->aResource instanceof Persistent) { - $this->aResource->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aGroup = null; - $this->aResource = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupResourcePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return GroupResource The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupResourcePeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php b/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php deleted file mode 100755 index 5c8fba516..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupResourcePeer.php +++ /dev/null @@ -1,1430 +0,0 @@ - array ('Id', 'GroupId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'groupId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (GroupResourcePeer::ID, GroupResourcePeer::GROUP_ID, GroupResourcePeer::RESOURCE_ID, GroupResourcePeer::READ, GroupResourcePeer::WRITE, GroupResourcePeer::CREATED_AT, GroupResourcePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'GROUP_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'group_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. GroupResourcePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'GroupId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'groupId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (GroupResourcePeer::ID => 0, GroupResourcePeer::GROUP_ID => 1, GroupResourcePeer::RESOURCE_ID => 2, GroupResourcePeer::READ => 3, GroupResourcePeer::WRITE => 4, GroupResourcePeer::CREATED_AT => 5, GroupResourcePeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'GROUP_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'group_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = GroupResourcePeer::getFieldNames($toType); - $key = isset(GroupResourcePeer::$fieldKeys[$fromType][$name]) ? GroupResourcePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(GroupResourcePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, GroupResourcePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return GroupResourcePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. GroupResourcePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(GroupResourcePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupResourcePeer::ID); - $criteria->addSelectColumn(GroupResourcePeer::GROUP_ID); - $criteria->addSelectColumn(GroupResourcePeer::RESOURCE_ID); - $criteria->addSelectColumn(GroupResourcePeer::READ); - $criteria->addSelectColumn(GroupResourcePeer::WRITE); - $criteria->addSelectColumn(GroupResourcePeer::CREATED_AT); - $criteria->addSelectColumn(GroupResourcePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.group_id'); - $criteria->addSelectColumn($alias . '.resource_id'); - $criteria->addSelectColumn($alias . '.read'); - $criteria->addSelectColumn($alias . '.write'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return GroupResource - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = GroupResourcePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return GroupResourcePeer::populateObjects(GroupResourcePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - GroupResourcePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param GroupResource $obj A GroupResource object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getResourceId())); - } // if key === null - GroupResourcePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A GroupResource object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof GroupResource) { - $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getResourceId())); - } elseif (is_array($value) && count($value) === 3) { - // assume we've been passed a primary key - $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or GroupResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(GroupResourcePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return GroupResource Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(GroupResourcePeer::$instances[$key])) { - return GroupResourcePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (GroupResourcePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - GroupResourcePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to group_resource - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null && $row[$startcol + 2] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1], (string) $row[$startcol + 2])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (int) $row[$startcol + 1], (int) $row[$startcol + 2]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = GroupResourcePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = GroupResourcePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupResourcePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (GroupResource object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = GroupResourcePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = GroupResourcePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + GroupResourcePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupResourcePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - GroupResourcePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Resource table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinResource(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of GroupResource objects pre-filled with their Group objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupResource objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - } - - GroupResourcePeer::addSelectColumns($criteria); - $startcol = GroupResourcePeer::NUM_HYDRATE_COLUMNS; - GroupPeer::addSelectColumns($criteria); - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = GroupResourcePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (GroupResource) to $obj2 (Group) - $obj2->addGroupResource($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of GroupResource objects pre-filled with their Resource objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupResource objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - } - - GroupResourcePeer::addSelectColumns($criteria); - $startcol = GroupResourcePeer::NUM_HYDRATE_COLUMNS; - ResourcePeer::addSelectColumns($criteria); - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = GroupResourcePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ResourcePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ResourcePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ResourcePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (GroupResource) to $obj2 (Resource) - $obj2->addGroupResource($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of GroupResource objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupResource objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - } - - GroupResourcePeer::addSelectColumns($criteria); - $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - ResourcePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ResourcePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupResourcePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (GroupResource) to the collection in $obj2 (Group) - $obj2->addGroupResource($obj1); - } // if joined row not null - - // Add objects for joined Resource rows - - $key3 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ResourcePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ResourcePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ResourcePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (GroupResource) to the collection in $obj3 (Resource) - $obj3->addGroupResource($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Group table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptGroup(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Resource table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptResource(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - GroupResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of GroupResource objects pre-filled with all related objects except Group. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupResource objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptGroup(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - } - - GroupResourcePeer::addSelectColumns($criteria); - $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS; - - ResourcePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ResourcePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupResourcePeer::RESOURCE_ID, ResourcePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupResourcePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Resource rows - - $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ResourcePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ResourcePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ResourcePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (GroupResource) to the collection in $obj2 (Resource) - $obj2->addGroupResource($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of GroupResource objects pre-filled with all related objects except Resource. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of GroupResource objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - } - - GroupResourcePeer::addSelectColumns($criteria); - $startcol2 = GroupResourcePeer::NUM_HYDRATE_COLUMNS; - - GroupPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + GroupPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(GroupResourcePeer::GROUP_ID, GroupPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = GroupResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = GroupResourcePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = GroupResourcePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Group rows - - $key2 = GroupPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = GroupPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = GroupPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - GroupPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (GroupResource) to the collection in $obj2 (Group) - $obj2->addGroupResource($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(GroupResourcePeer::DATABASE_NAME)->getTable(GroupResourcePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseGroupResourcePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseGroupResourcePeer::TABLE_NAME)) { - $dbMap->addTableObject(new GroupResourceTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return GroupResourcePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a GroupResource or Criteria object. - * - * @param mixed $values Criteria or GroupResource object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from GroupResource object - } - - if ($criteria->containsKey(GroupResourcePeer::ID) && $criteria->keyContainsValue(GroupResourcePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupResourcePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a GroupResource or Criteria object. - * - * @param mixed $values Criteria or GroupResource object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(GroupResourcePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(GroupResourcePeer::ID); - $value = $criteria->remove(GroupResourcePeer::ID); - if ($value) { - $selectCriteria->add(GroupResourcePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(GroupResourcePeer::GROUP_ID); - $value = $criteria->remove(GroupResourcePeer::GROUP_ID); - if ($value) { - $selectCriteria->add(GroupResourcePeer::GROUP_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(GroupResourcePeer::RESOURCE_ID); - $value = $criteria->remove(GroupResourcePeer::RESOURCE_ID); - if ($value) { - $selectCriteria->add(GroupResourcePeer::RESOURCE_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(GroupResourcePeer::TABLE_NAME); - } - - } else { // $values is GroupResource object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the group_resource table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(GroupResourcePeer::TABLE_NAME, $con, GroupResourcePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupResourcePeer::clearInstancePool(); - GroupResourcePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a GroupResource or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupResource object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - GroupResourcePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof GroupResource) { // it's a model object - // invalidate the cache for this single object - GroupResourcePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME); - // 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(GroupResourcePeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(GroupResourcePeer::GROUP_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(GroupResourcePeer::RESOURCE_ID, $value[2])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - GroupResourcePeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(GroupResourcePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - GroupResourcePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given GroupResource object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param GroupResource $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(GroupResourcePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(GroupResourcePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(GroupResourcePeer::DATABASE_NAME, GroupResourcePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param int $group_id - * @param int $resource_id - * @param PropelPDO $con - * @return GroupResource - */ - public static function retrieveByPK($id, $group_id, $resource_id, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $group_id, (string) $resource_id)); - if (null !== ($obj = GroupResourcePeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(GroupResourcePeer::DATABASE_NAME); - $criteria->add(GroupResourcePeer::ID, $id); - $criteria->add(GroupResourcePeer::GROUP_ID, $group_id); - $criteria->add(GroupResourcePeer::RESOURCE_ID, $resource_id); - $v = GroupResourcePeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseGroupResourcePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseGroupResourcePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php b/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php deleted file mode 100755 index d6ff84c8b..000000000 --- a/core/lib/Thelia/Model/om/BaseGroupResourceQuery.php +++ /dev/null @@ -1,803 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34, 56), $con); - * - * - * @param array $key Primary key to use for the query - A Primary key composition: [$id, $group_id, $resource_id] - * @param PropelPDO $con an optional connection object - * - * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupResourcePeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(GroupResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return GroupResource A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `group_id`, `resource_id`, `read`, `write`, `created_at`, `updated_at` FROM `group_resource` WHERE `id` = :p0 AND `group_id` = :p1 AND `resource_id` = :p2'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new GroupResource(); - $obj->hydrate($row); - GroupResourcePeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return GroupResource|GroupResource[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(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|GroupResource[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(GroupResourcePeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $key[2], 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 GroupResourceQuery 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(GroupResourcePeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(GroupResourcePeer::GROUP_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(GroupResourcePeer::RESOURCE_ID, $key[2], Criteria::EQUAL); - $cton0->addAnd($cton2); - $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id >= 12 - * $query->filterByGroupId(array('max' => 12)); // WHERE group_id <= 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the resource_id column - * - * Example usage: - * - * $query->filterByResourceId(1234); // WHERE resource_id = 1234 - * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34) - * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id >= 12 - * $query->filterByResourceId(array('max' => 12)); // WHERE resource_id <= 12 - * - * - * @see filterByResource() - * - * @param mixed $resourceId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByResourceId($resourceId = null, $comparison = null) - { - if (is_array($resourceId)) { - $useMinMax = false; - if (isset($resourceId['min'])) { - $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($resourceId['max'])) { - $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resourceId, $comparison); - } - - /** - * Filter the query on the read column - * - * Example usage: - * - * $query->filterByRead(1234); // WHERE read = 1234 - * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) - * $query->filterByRead(array('min' => 12)); // WHERE read >= 12 - * $query->filterByRead(array('max' => 12)); // WHERE read <= 12 - * - * - * @param mixed $read The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByRead($read = null, $comparison = null) - { - if (is_array($read)) { - $useMinMax = false; - if (isset($read['min'])) { - $this->addUsingAlias(GroupResourcePeer::READ, $read['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($read['max'])) { - $this->addUsingAlias(GroupResourcePeer::READ, $read['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::READ, $read, $comparison); - } - - /** - * Filter the query on the write column - * - * Example usage: - * - * $query->filterByWrite(1234); // WHERE write = 1234 - * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) - * $query->filterByWrite(array('min' => 12)); // WHERE write >= 12 - * $query->filterByWrite(array('max' => 12)); // WHERE write <= 12 - * - * - * @param mixed $write The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByWrite($write = null, $comparison = null) - { - if (is_array($write)) { - $useMinMax = false; - if (isset($write['min'])) { - $this->addUsingAlias(GroupResourcePeer::WRITE, $write['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($write['max'])) { - $this->addUsingAlias(GroupResourcePeer::WRITE, $write['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::WRITE, $write, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Group object - * - * @param Group|PropelObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof Group) { - return $this - ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupResourcePeer::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type Group or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related Resource object - * - * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return GroupResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByResource($resource, $comparison = null) - { - if ($resource instanceof Resource) { - return $this - ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->getId(), $comparison); - } elseif ($resource instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupResourcePeer::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Resource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Resource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Resource'); - } - - return $this; - } - - /** - * Use the Resource relation Resource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query - */ - public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery'); - } - - /** - * Exclude object from result - * - * @param GroupResource $groupResource Object to remove from the list of results - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function prune($groupResource = null) - { - if ($groupResource) { - $this->addCond('pruneCond0', $this->getAliasedColName(GroupResourcePeer::ID), $groupResource->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(GroupResourcePeer::GROUP_ID), $groupResource->getGroupId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(GroupResourcePeer::RESOURCE_ID), $groupResource->getResourceId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupResourcePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupResourcePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupResourcePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return GroupResourceQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupResourcePeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseImage.php b/core/lib/Thelia/Model/om/BaseImage.php deleted file mode 100755 index 8443cb379..000000000 --- a/core/lib/Thelia/Model/om/BaseImage.php +++ /dev/null @@ -1,2193 +0,0 @@ -id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - return $this->folder_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - return $this->content_id; - } - - /** - * Get the [file] column value. - * - * @return string - */ - public function getFile() - { - return $this->file; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ImagePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = ImagePeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = ImagePeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = ImagePeer::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = ImagePeer::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Set the value of [file] column. - * - * @param string $v new value - * @return Image The current object (for fluent API support) - */ - public function setFile($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->file !== $v) { - $this->file = $v; - $this->modifiedColumns[] = ImagePeer::FILE; - } - - - return $this; - } // setFile() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Image The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ImagePeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Image The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ImagePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Image The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ImagePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->category_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->folder_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->content_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->file = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->position = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->created_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->updated_at = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = ImagePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Image object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ImagePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; - $this->collImageI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ImageQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ImagePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ImagePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ImagePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ImagePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->imageI18nsScheduledForDeletion !== null) { - if (!$this->imageI18nsScheduledForDeletion->isEmpty()) { - ImageI18nQuery::create() - ->filterByPrimaryKeys($this->imageI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->imageI18nsScheduledForDeletion = null; - } - } - - if ($this->collImageI18ns !== null) { - foreach ($this->collImageI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ImagePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ImagePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ImagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(ImagePeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; - } - if ($this->isColumnModified(ImagePeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; - } - if ($this->isColumnModified(ImagePeer::FILE)) { - $modifiedColumns[':p' . $index++] = '`file`'; - } - if ($this->isColumnModified(ImagePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(ImagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ImagePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `image` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`folder_id`': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case '`content_id`': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case '`file`': - $stmt->bindValue($identifier, $this->file, PDO::PARAM_STR); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aContent !== null) { - if (!$this->aContent->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures()); - } - } - - if ($this->aFolder !== null) { - if (!$this->aFolder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures()); - } - } - - - if (($retval = ImagePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collImageI18ns !== null) { - foreach ($this->collImageI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getProductId(); - break; - case 2: - return $this->getCategoryId(); - break; - case 3: - return $this->getFolderId(); - break; - case 4: - return $this->getContentId(); - break; - case 5: - return $this->getFile(); - break; - case 6: - return $this->getPosition(); - break; - case 7: - return $this->getCreatedAt(); - break; - case 8: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Image'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Image'][$this->getPrimaryKey()] = true; - $keys = ImagePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getProductId(), - $keys[2] => $this->getCategoryId(), - $keys[3] => $this->getFolderId(), - $keys[4] => $this->getContentId(), - $keys[5] => $this->getFile(), - $keys[6] => $this->getPosition(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collImageI18ns) { - $result['ImageI18ns'] = $this->collImageI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ImagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setProductId($value); - break; - case 2: - $this->setCategoryId($value); - break; - case 3: - $this->setFolderId($value); - break; - case 4: - $this->setContentId($value); - break; - case 5: - $this->setFile($value); - break; - case 6: - $this->setPosition($value); - break; - case 7: - $this->setCreatedAt($value); - break; - case 8: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ImagePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCategoryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFolderId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setContentId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setFile($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setPosition($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - - if ($this->isColumnModified(ImagePeer::ID)) $criteria->add(ImagePeer::ID, $this->id); - if ($this->isColumnModified(ImagePeer::PRODUCT_ID)) $criteria->add(ImagePeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(ImagePeer::CATEGORY_ID)) $criteria->add(ImagePeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(ImagePeer::FOLDER_ID)) $criteria->add(ImagePeer::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(ImagePeer::CONTENT_ID)) $criteria->add(ImagePeer::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(ImagePeer::FILE)) $criteria->add(ImagePeer::FILE, $this->file); - if ($this->isColumnModified(ImagePeer::POSITION)) $criteria->add(ImagePeer::POSITION, $this->position); - if ($this->isColumnModified(ImagePeer::CREATED_AT)) $criteria->add(ImagePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ImagePeer::UPDATED_AT)) $criteria->add(ImagePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - $criteria->add(ImagePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Image (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setFile($this->getFile()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getImageI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImageI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Image Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ImagePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ImagePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Image The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addImages($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return Image The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addImages($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return Image The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(Content $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Content object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addImages($this); - */ - } - - return $this->aContent; - } - - /** - * Declares an association between this object and a Folder object. - * - * @param Folder $v - * @return Image The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(Folder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Folder object, it will not be re-added. - if ($v !== null) { - $v->addImage($this); - } - - - return $this; - } - - - /** - * Get the associated Folder object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addImages($this); - */ - } - - return $this->aFolder; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('ImageI18n' == $relationName) { - $this->initImageI18ns(); - } - } - - /** - * Clears out the collImageI18ns 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 Image The current object (for fluent API support) - * @see addImageI18ns() - */ - public function clearImageI18ns() - { - $this->collImageI18ns = null; // important to set this to null since that means it is uninitialized - $this->collImageI18nsPartial = null; - - return $this; - } - - /** - * reset is the collImageI18ns collection loaded partially - * - * @return void - */ - public function resetPartialImageI18ns($v = true) - { - $this->collImageI18nsPartial = $v; - } - - /** - * Initializes the collImageI18ns collection. - * - * By default this just sets the collImageI18ns collection to an empty array (like clearcollImageI18ns()); - * 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 initImageI18ns($overrideExisting = true) - { - if (null !== $this->collImageI18ns && !$overrideExisting) { - return; - } - $this->collImageI18ns = new PropelObjectCollection(); - $this->collImageI18ns->setModel('ImageI18n'); - } - - /** - * Gets an array of ImageI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Image is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ImageI18n[] List of ImageI18n objects - * @throws PropelException - */ - public function getImageI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImageI18nsPartial && !$this->isNew(); - if (null === $this->collImageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImageI18ns) { - // return empty collection - $this->initImageI18ns(); - } else { - $collImageI18ns = ImageI18nQuery::create(null, $criteria) - ->filterByImage($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImageI18nsPartial && count($collImageI18ns)) { - $this->initImageI18ns(false); - - foreach($collImageI18ns as $obj) { - if (false == $this->collImageI18ns->contains($obj)) { - $this->collImageI18ns->append($obj); - } - } - - $this->collImageI18nsPartial = true; - } - - $collImageI18ns->getInternalIterator()->rewind(); - return $collImageI18ns; - } - - if($partial && $this->collImageI18ns) { - foreach($this->collImageI18ns as $obj) { - if($obj->isNew()) { - $collImageI18ns[] = $obj; - } - } - } - - $this->collImageI18ns = $collImageI18ns; - $this->collImageI18nsPartial = false; - } - } - - return $this->collImageI18ns; - } - - /** - * Sets a collection of ImageI18n 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 $imageI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Image The current object (for fluent API support) - */ - public function setImageI18ns(PropelCollection $imageI18ns, PropelPDO $con = null) - { - $imageI18nsToDelete = $this->getImageI18ns(new Criteria(), $con)->diff($imageI18ns); - - $this->imageI18nsScheduledForDeletion = unserialize(serialize($imageI18nsToDelete)); - - foreach ($imageI18nsToDelete as $imageI18nRemoved) { - $imageI18nRemoved->setImage(null); - } - - $this->collImageI18ns = null; - foreach ($imageI18ns as $imageI18n) { - $this->addImageI18n($imageI18n); - } - - $this->collImageI18ns = $imageI18ns; - $this->collImageI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ImageI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ImageI18n objects. - * @throws PropelException - */ - public function countImageI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImageI18nsPartial && !$this->isNew(); - if (null === $this->collImageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImageI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getImageI18ns()); - } - $query = ImageI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByImage($this) - ->count($con); - } - - return count($this->collImageI18ns); - } - - /** - * Method called to associate a ImageI18n object to this object - * through the ImageI18n foreign key attribute. - * - * @param ImageI18n $l ImageI18n - * @return Image The current object (for fluent API support) - */ - public function addImageI18n(ImageI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collImageI18ns === null) { - $this->initImageI18ns(); - $this->collImageI18nsPartial = true; - } - if (!in_array($l, $this->collImageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImageI18n($l); - } - - return $this; - } - - /** - * @param ImageI18n $imageI18n The imageI18n object to add. - */ - protected function doAddImageI18n($imageI18n) - { - $this->collImageI18ns[]= $imageI18n; - $imageI18n->setImage($this); - } - - /** - * @param ImageI18n $imageI18n The imageI18n object to remove. - * @return Image The current object (for fluent API support) - */ - public function removeImageI18n($imageI18n) - { - if ($this->getImageI18ns()->contains($imageI18n)) { - $this->collImageI18ns->remove($this->collImageI18ns->search($imageI18n)); - if (null === $this->imageI18nsScheduledForDeletion) { - $this->imageI18nsScheduledForDeletion = clone $this->collImageI18ns; - $this->imageI18nsScheduledForDeletion->clear(); - } - $this->imageI18nsScheduledForDeletion[]= clone $imageI18n; - $imageI18n->setImage(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; - $this->content_id = null; - $this->file = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collImageI18ns) { - foreach ($this->collImageI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collImageI18ns instanceof PropelCollection) { - $this->collImageI18ns->clearIterator(); - } - $this->collImageI18ns = null; - $this->aProduct = null; - $this->aCategory = null; - $this->aContent = null; - $this->aFolder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ImagePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Image The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ImagePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Image The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ImageI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collImageI18ns) { - foreach ($this->collImageI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ImageI18n(); - $translation->setLocale($locale); - } else { - $translation = ImageI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addImageI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Image The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ImageI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collImageI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collImageI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ImageI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseImageI18n.php b/core/lib/Thelia/Model/om/BaseImageI18n.php deleted file mode 100755 index bafb3b7bb..000000000 --- a/core/lib/Thelia/Model/om/BaseImageI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseImageI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ImageI18nPeer::ID; - } - - if ($this->aImage !== null && $this->aImage->getId() !== $v) { - $this->aImage = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ImageI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ImageI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ImageI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ImageI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ImageI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ImageI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ImageI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ImageI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aImage !== null && $this->id !== $this->aImage->getId()) { - $this->aImage = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::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 = ImageI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aImage = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ImageI18nQuery::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(ImageI18nPeer::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); - ImageI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aImage !== null) { - if ($this->aImage->isModified() || $this->aImage->isNew()) { - $affectedRows += $this->aImage->save($con); - } - $this->setImage($this->aImage); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ImageI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ImageI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ImageI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ImageI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ImageI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ImageI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `image_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aImage !== null) { - if (!$this->aImage->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aImage->getValidationFailures()); - } - } - - - if (($retval = ImageI18nPeer::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 = ImageI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ImageI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ImageI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ImageI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aImage) { - $result['Image'] = $this->aImage->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ImageI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ImageI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ImageI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ImageI18nPeer::ID)) $criteria->add(ImageI18nPeer::ID, $this->id); - if ($this->isColumnModified(ImageI18nPeer::LOCALE)) $criteria->add(ImageI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ImageI18nPeer::TITLE)) $criteria->add(ImageI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ImageI18nPeer::DESCRIPTION)) $criteria->add(ImageI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ImageI18nPeer::CHAPO)) $criteria->add(ImageI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ImageI18nPeer::POSTSCRIPTUM)) $criteria->add(ImageI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ImageI18nPeer::DATABASE_NAME); - $criteria->add(ImageI18nPeer::ID, $this->id); - $criteria->add(ImageI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ImageI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ImageI18n 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 ImageI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ImageI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Image object. - * - * @param Image $v - * @return ImageI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setImage(Image $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aImage = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Image object, it will not be re-added. - if ($v !== null) { - $v->addImageI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Image object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Image The associated Image object. - * @throws PropelException - */ - public function getImage(PropelPDO $con = null, $doQuery = true) - { - if ($this->aImage === null && ($this->id !== null) && $doQuery) { - $this->aImage = ImageQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aImage->addImageI18ns($this); - */ - } - - return $this->aImage; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aImage instanceof Persistent) { - $this->aImage->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aImage = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ImageI18nPeer::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/BaseImageI18nPeer.php b/core/lib/Thelia/Model/om/BaseImageI18nPeer.php deleted file mode 100755 index b831c19a1..000000000 --- a/core/lib/Thelia/Model/om/BaseImageI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ImageI18nPeer::ID, ImageI18nPeer::LOCALE, ImageI18nPeer::TITLE, ImageI18nPeer::DESCRIPTION, ImageI18nPeer::CHAPO, ImageI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ImageI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ImageI18nPeer::ID => 0, ImageI18nPeer::LOCALE => 1, ImageI18nPeer::TITLE => 2, ImageI18nPeer::DESCRIPTION => 3, ImageI18nPeer::CHAPO => 4, ImageI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ImageI18nPeer::getFieldNames($toType); - $key = isset(ImageI18nPeer::$fieldKeys[$fromType][$name]) ? ImageI18nPeer::$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(ImageI18nPeer::$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, ImageI18nPeer::$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 ImageI18nPeer::$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. ImageI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ImageI18nPeer::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(ImageI18nPeer::ID); - $criteria->addSelectColumn(ImageI18nPeer::LOCALE); - $criteria->addSelectColumn(ImageI18nPeer::TITLE); - $criteria->addSelectColumn(ImageI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ImageI18nPeer::CHAPO); - $criteria->addSelectColumn(ImageI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ImageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::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 ImageI18n - * @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 = ImageI18nPeer::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 ImageI18nPeer::populateObjects(ImageI18nPeer::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 directly (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(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ImageI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ImageI18nPeer::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 ImageI18n $obj A ImageI18n 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->getLocale())); - } // if key === null - ImageI18nPeer::$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 ImageI18n 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 ImageI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ImageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ImageI18nPeer::$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 ImageI18n 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(ImageI18nPeer::$instances[$key])) { - return ImageI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ImageI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ImageI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to image_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ImageI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ImageI18nPeer::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; - ImageI18nPeer::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 (ImageI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ImageI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ImageI18nPeer::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 + ImageI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ImageI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ImageI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Image table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinImage(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ImageI18n objects pre-filled with their Image objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ImageI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinImage(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); - } - - ImageI18nPeer::addSelectColumns($criteria); - $startcol = ImageI18nPeer::NUM_HYDRATE_COLUMNS; - ImagePeer::addSelectColumns($criteria); - - $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImageI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ImageI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImageI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ImagePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ImagePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ImagePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ImageI18n) to $obj2 (Image) - $obj2->addImageI18n($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(ImageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ImageI18n 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 ImageI18n 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(ImageI18nPeer::DATABASE_NAME); - } - - ImageI18nPeer::addSelectColumns($criteria); - $startcol2 = ImageI18nPeer::NUM_HYDRATE_COLUMNS; - - ImagePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ImagePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImageI18nPeer::ID, ImagePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImageI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImageI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImageI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Image rows - - $key2 = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ImagePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ImagePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ImagePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ImageI18n) to the collection in $obj2 (Image) - $obj2->addImageI18n($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(ImageI18nPeer::DATABASE_NAME)->getTable(ImageI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseImageI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseImageI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ImageI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ImageI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ImageI18n or Criteria object. - * - * @param mixed $values Criteria or ImageI18n 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(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ImageI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ImageI18nPeer::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 ImageI18n or Criteria object. - * - * @param mixed $values Criteria or ImageI18n 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(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ImageI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ImageI18nPeer::ID); - $value = $criteria->remove(ImageI18nPeer::ID); - if ($value) { - $selectCriteria->add(ImageI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ImageI18nPeer::LOCALE); - $value = $criteria->remove(ImageI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ImageI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ImageI18nPeer::TABLE_NAME); - } - - } else { // $values is ImageI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ImageI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the image_i18n 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(ImageI18nPeer::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(ImageI18nPeer::TABLE_NAME, $con, ImageI18nPeer::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). - ImageI18nPeer::clearInstancePool(); - ImageI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ImageI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ImageI18n 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(ImageI18nPeer::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. - ImageI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ImageI18n) { // it's a model object - // invalidate the cache for this single object - ImageI18nPeer::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(ImageI18nPeer::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(ImageI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ImageI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ImageI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ImageI18nPeer::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); - ImageI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ImageI18n 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 ImageI18n $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(ImageI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ImageI18nPeer::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(ImageI18nPeer::DATABASE_NAME, ImageI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ImageI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ImageI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ImageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ImageI18nPeer::DATABASE_NAME); - $criteria->add(ImageI18nPeer::ID, $id); - $criteria->add(ImageI18nPeer::LOCALE, $locale); - $v = ImageI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseImageI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseImageI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php b/core/lib/Thelia/Model/om/BaseImageI18nQuery.php deleted file mode 100755 index be9c773a5..000000000 --- a/core/lib/Thelia/Model/om/BaseImageI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ImageI18n|ImageI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ImageI18nPeer::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(ImageI18nPeer::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 ImageI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `image_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ImageI18n(); - $obj->hydrate($row); - ImageI18nPeer::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 ImageI18n|ImageI18n[]|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|ImageI18n[]|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 ImageI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ImageI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ImageI18nPeer::LOCALE, $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 ImageI18nQuery 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(ImageI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ImageI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByImage() - * - * @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 ImageI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ImageI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ImageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImageI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ImageI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImageI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Image object - * - * @param Image|PropelObjectCollection $image The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(ImageI18nPeer::ID, $image->getId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImageI18nPeer::ID, $image->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Exclude object from result - * - * @param ImageI18n $imageI18n Object to remove from the list of results - * - * @return ImageI18nQuery The current query, for fluid interface - */ - public function prune($imageI18n = null) - { - if ($imageI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ImageI18nPeer::ID), $imageI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ImageI18nPeer::LOCALE), $imageI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseImagePeer.php b/core/lib/Thelia/Model/om/BaseImagePeer.php deleted file mode 100755 index cf991dbfd..000000000 --- a/core/lib/Thelia/Model/om/BaseImagePeer.php +++ /dev/null @@ -1,2200 +0,0 @@ - array ('Id', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'File', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'productId', 'categoryId', 'folderId', 'contentId', 'file', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ImagePeer::ID, ImagePeer::PRODUCT_ID, ImagePeer::CATEGORY_ID, ImagePeer::FOLDER_ID, ImagePeer::CONTENT_ID, ImagePeer::FILE, ImagePeer::POSITION, ImagePeer::CREATED_AT, ImagePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'FILE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'product_id', 'category_id', 'folder_id', 'content_id', 'file', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ImagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'ProductId' => 1, 'CategoryId' => 2, 'FolderId' => 3, 'ContentId' => 4, 'File' => 5, 'Position' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'productId' => 1, 'categoryId' => 2, 'folderId' => 3, 'contentId' => 4, 'file' => 5, 'position' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - BasePeer::TYPE_COLNAME => array (ImagePeer::ID => 0, ImagePeer::PRODUCT_ID => 1, ImagePeer::CATEGORY_ID => 2, ImagePeer::FOLDER_ID => 3, ImagePeer::CONTENT_ID => 4, ImagePeer::FILE => 5, ImagePeer::POSITION => 6, ImagePeer::CREATED_AT => 7, ImagePeer::UPDATED_AT => 8, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'PRODUCT_ID' => 1, 'CATEGORY_ID' => 2, 'FOLDER_ID' => 3, 'CONTENT_ID' => 4, 'FILE' => 5, 'POSITION' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'product_id' => 1, 'category_id' => 2, 'folder_id' => 3, 'content_id' => 4, 'file' => 5, 'position' => 6, 'created_at' => 7, 'updated_at' => 8, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ImagePeer::getFieldNames($toType); - $key = isset(ImagePeer::$fieldKeys[$fromType][$name]) ? ImagePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ImagePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ImagePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ImagePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ImagePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ImagePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ImagePeer::ID); - $criteria->addSelectColumn(ImagePeer::PRODUCT_ID); - $criteria->addSelectColumn(ImagePeer::CATEGORY_ID); - $criteria->addSelectColumn(ImagePeer::FOLDER_ID); - $criteria->addSelectColumn(ImagePeer::CONTENT_ID); - $criteria->addSelectColumn(ImagePeer::FILE); - $criteria->addSelectColumn(ImagePeer::POSITION); - $criteria->addSelectColumn(ImagePeer::CREATED_AT); - $criteria->addSelectColumn(ImagePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.folder_id'); - $criteria->addSelectColumn($alias . '.content_id'); - $criteria->addSelectColumn($alias . '.file'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ImagePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Image - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ImagePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ImagePeer::populateObjects(ImagePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ImagePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Image $obj A Image object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ImagePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Image object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Image) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Image object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ImagePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Image Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ImagePeer::$instances[$key])) { - return ImagePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ImagePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ImagePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to image - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ImageI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImageI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ImagePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ImagePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ImagePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Image object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ImagePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ImagePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ImagePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ImagePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ImagePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Image objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol = ImagePeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Image) to $obj2 (Product) - $obj2->addImage($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol = ImagePeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Image) to $obj2 (Category) - $obj2->addImage($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with their Content objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol = ImagePeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Image) to $obj2 (Content) - $obj2->addImage($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with their Folder objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol = ImagePeer::NUM_HYDRATE_COLUMNS; - FolderPeer::addSelectColumns($criteria); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FolderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FolderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FolderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Image) to $obj2 (Folder) - $obj2->addImage($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Image objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Image) to the collection in $obj2 (Product) - $obj2->addImage($obj1); - } // if joined row not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Image) to the collection in $obj3 (Category) - $obj3->addImage($obj1); - } // if joined row not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (Image) to the collection in $obj4 (Content) - $obj4->addImage($obj1); - } // if joined row not null - - // Add objects for joined Folder rows - - $key5 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = FolderPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = FolderPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - FolderPeer::addInstanceToPool($obj5, $key5); - } // if obj5 loaded - - // Add the $obj1 (Image) to the collection in $obj5 (Folder) - $obj5->addImage($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ImagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Image objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Image) to the collection in $obj2 (Category) - $obj2->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Image) to the collection in $obj3 (Content) - $obj3->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Image) to the collection in $obj4 (Folder) - $obj4->addImage($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ContentPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Image) to the collection in $obj2 (Product) - $obj2->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key3 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ContentPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ContentPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ContentPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Image) to the collection in $obj3 (Content) - $obj3->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Image) to the collection in $obj4 (Folder) - $obj4->addImage($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with all related objects except Content. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Image) to the collection in $obj2 (Product) - $obj2->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Image) to the collection in $obj3 (Category) - $obj3->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Image) to the collection in $obj4 (Folder) - $obj4->addImage($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Image objects pre-filled with all related objects except Folder. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Image objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ImagePeer::DATABASE_NAME); - } - - ImagePeer::addSelectColumns($criteria); - $startcol2 = ImagePeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ImagePeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(ImagePeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ImagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ImagePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ImagePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ImagePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Image) to the collection in $obj2 (Product) - $obj2->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Image) to the collection in $obj3 (Category) - $obj3->addImage($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Image) to the collection in $obj4 (Content) - $obj4->addImage($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ImagePeer::DATABASE_NAME)->getTable(ImagePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseImagePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseImagePeer::TABLE_NAME)) { - $dbMap->addTableObject(new ImageTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ImagePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Image or Criteria object. - * - * @param mixed $values Criteria or Image object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Image object - } - - if ($criteria->containsKey(ImagePeer::ID) && $criteria->keyContainsValue(ImagePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ImagePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Image or Criteria object. - * - * @param mixed $values Criteria or Image object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ImagePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ImagePeer::ID); - $value = $criteria->remove(ImagePeer::ID); - if ($value) { - $selectCriteria->add(ImagePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ImagePeer::TABLE_NAME); - } - - } else { // $values is Image object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the image table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ImagePeer::TABLE_NAME, $con, ImagePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ImagePeer::clearInstancePool(); - ImagePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Image or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Image object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ImagePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Image) { // it's a model object - // invalidate the cache for this single object - ImagePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - $criteria->add(ImagePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ImagePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ImagePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ImagePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Image object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Image $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ImagePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ImagePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ImagePeer::DATABASE_NAME, ImagePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Image - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ImagePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - $criteria->add(ImagePeer::ID, $pk); - - $v = ImagePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Image[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ImagePeer::DATABASE_NAME); - $criteria->add(ImagePeer::ID, $pks, Criteria::IN); - $objs = ImagePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseImagePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseImagePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseImageQuery.php b/core/lib/Thelia/Model/om/BaseImageQuery.php deleted file mode 100755 index 44279b45d..000000000 --- a/core/lib/Thelia/Model/om/BaseImageQuery.php +++ /dev/null @@ -1,1177 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Image|Image[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ImagePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ImagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Image A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Image A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `product_id`, `category_id`, `folder_id`, `content_id`, `file`, `position`, `created_at`, `updated_at` FROM `image` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Image(); - $obj->hydrate($row); - ImagePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Image|Image[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Image[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ImagePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ImagePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ImagePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ImagePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 - * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 - * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the file column - * - * Example usage: - * - * $query->filterByFile('fooValue'); // WHERE file = 'fooValue' - * $query->filterByFile('%fooValue%'); // WHERE file LIKE '%fooValue%' - * - * - * @param string $file The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByFile($file = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($file)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $file)) { - $file = str_replace('*', '%', $file); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ImagePeer::FILE, $file, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ImagePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ImagePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ImagePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(ImagePeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImagePeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImagePeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Content object - * - * @param Content|PropelObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof Content) { - return $this - ->addUsingAlias(ImagePeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImagePeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Filter the query by a related Folder object - * - * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof Folder) { - return $this - ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ImagePeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related ImageI18n object - * - * @param ImageI18n|PropelObjectCollection $imageI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ImageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImageI18n($imageI18n, $comparison = null) - { - if ($imageI18n instanceof ImageI18n) { - return $this - ->addUsingAlias(ImagePeer::ID, $imageI18n->getId(), $comparison); - } elseif ($imageI18n instanceof PropelObjectCollection) { - return $this - ->useImageI18nQuery() - ->filterByPrimaryKeys($imageI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImageI18n() only accepts arguments of type ImageI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ImageI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinImageI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ImageI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ImageI18n'); - } - - return $this; - } - - /** - * Use the ImageI18n relation ImageI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageI18nQuery A secondary query class using the current class as primary query - */ - public function useImageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinImageI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', '\Thelia\Model\ImageI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Image $image Object to remove from the list of results - * - * @return ImageQuery The current query, for fluid interface - */ - public function prune($image = null) - { - if ($image) { - $this->addUsingAlias(ImagePeer::ID, $image->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ImageQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ImagePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ImageQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ImagePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ImageQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ImagePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ImageQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ImagePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ImageQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ImagePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ImageQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ImagePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ImageI18n'; - - return $this - ->joinImageI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ImageQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ImageI18n'); - $this->with['ImageI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ImageI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ImageI18n', 'Thelia\Model\ImageI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseLang.php b/core/lib/Thelia/Model/om/BaseLang.php deleted file mode 100755 index d54987f69..000000000 --- a/core/lib/Thelia/Model/om/BaseLang.php +++ /dev/null @@ -1,1252 +0,0 @@ -id; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [url] column value. - * - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Get the [by_default] column value. - * - * @return int - */ - public function getByDefault() - { - return $this->by_default; - } - - /** - * 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Lang The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = LangPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return Lang The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = LangPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Lang The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = LangPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return Lang The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = LangPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return Lang The current object (for fluent API support) - */ - public function setUrl($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->url !== $v) { - $this->url = $v; - $this->modifiedColumns[] = LangPeer::URL; - } - - - return $this; - } // setUrl() - - /** - * Set the value of [by_default] column. - * - * @param int $v new value - * @return Lang The current object (for fluent API support) - */ - public function setByDefault($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = LangPeer::BY_DEFAULT; - } - - - return $this; - } // setByDefault() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Lang The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = LangPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Lang The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = LangPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->title = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->code = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->locale = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->url = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->by_default = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = LangPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Lang object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = LangPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = LangQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(LangPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(LangPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(LangPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - LangPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = LangPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . LangPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(LangPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(LangPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(LangPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(LangPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(LangPeer::URL)) { - $modifiedColumns[':p' . $index++] = '`url`'; - } - if ($this->isColumnModified(LangPeer::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = '`by_default`'; - } - if ($this->isColumnModified(LangPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(LangPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `lang` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`url`': - $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); - break; - case '`by_default`': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = LangPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = LangPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getTitle(); - break; - case 2: - return $this->getCode(); - break; - case 3: - return $this->getLocale(); - break; - case 4: - return $this->getUrl(); - break; - case 5: - return $this->getByDefault(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) - { - if (isset($alreadyDumpedObjects['Lang'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Lang'][$this->getPrimaryKey()] = true; - $keys = LangPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getTitle(), - $keys[2] => $this->getCode(), - $keys[3] => $this->getLocale(), - $keys[4] => $this->getUrl(), - $keys[5] => $this->getByDefault(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = LangPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setTitle($value); - break; - case 2: - $this->setCode($value); - break; - case 3: - $this->setLocale($value); - break; - case 4: - $this->setUrl($value); - break; - case 5: - $this->setByDefault($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = LangPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setTitle($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCode($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setLocale($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUrl($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setByDefault($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(LangPeer::DATABASE_NAME); - - if ($this->isColumnModified(LangPeer::ID)) $criteria->add(LangPeer::ID, $this->id); - if ($this->isColumnModified(LangPeer::TITLE)) $criteria->add(LangPeer::TITLE, $this->title); - if ($this->isColumnModified(LangPeer::CODE)) $criteria->add(LangPeer::CODE, $this->code); - if ($this->isColumnModified(LangPeer::LOCALE)) $criteria->add(LangPeer::LOCALE, $this->locale); - if ($this->isColumnModified(LangPeer::URL)) $criteria->add(LangPeer::URL, $this->url); - if ($this->isColumnModified(LangPeer::BY_DEFAULT)) $criteria->add(LangPeer::BY_DEFAULT, $this->by_default); - if ($this->isColumnModified(LangPeer::CREATED_AT)) $criteria->add(LangPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(LangPeer::UPDATED_AT)) $criteria->add(LangPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(LangPeer::DATABASE_NAME); - $criteria->add(LangPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Lang (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setTitle($this->getTitle()); - $copyObj->setCode($this->getCode()); - $copyObj->setLocale($this->getLocale()); - $copyObj->setUrl($this->getUrl()); - $copyObj->setByDefault($this->getByDefault()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Lang Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return LangPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new LangPeer(); - } - - return self::$peer; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->title = null; - $this->code = null; - $this->locale = null; - $this->url = null; - $this->by_default = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(LangPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Lang The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = LangPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseLangPeer.php b/core/lib/Thelia/Model/om/BaseLangPeer.php deleted file mode 100755 index 671fb9678..000000000 --- a/core/lib/Thelia/Model/om/BaseLangPeer.php +++ /dev/null @@ -1,805 +0,0 @@ - array ('Id', 'Title', 'Code', 'Locale', 'Url', 'ByDefault', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'title', 'code', 'locale', 'url', 'byDefault', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (LangPeer::ID, LangPeer::TITLE, LangPeer::CODE, LangPeer::LOCALE, LangPeer::URL, LangPeer::BY_DEFAULT, LangPeer::CREATED_AT, LangPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TITLE', 'CODE', 'LOCALE', 'URL', 'BY_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'title', 'code', 'locale', 'url', 'by_default', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. LangPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Title' => 1, 'Code' => 2, 'Locale' => 3, 'Url' => 4, 'ByDefault' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'byDefault' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (LangPeer::ID => 0, LangPeer::TITLE => 1, LangPeer::CODE => 2, LangPeer::LOCALE => 3, LangPeer::URL => 4, LangPeer::BY_DEFAULT => 5, LangPeer::CREATED_AT => 6, LangPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TITLE' => 1, 'CODE' => 2, 'LOCALE' => 3, 'URL' => 4, 'BY_DEFAULT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'title' => 1, 'code' => 2, 'locale' => 3, 'url' => 4, 'by_default' => 5, 'created_at' => 6, 'updated_at' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = LangPeer::getFieldNames($toType); - $key = isset(LangPeer::$fieldKeys[$fromType][$name]) ? LangPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(LangPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, LangPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return LangPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. LangPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(LangPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(LangPeer::ID); - $criteria->addSelectColumn(LangPeer::TITLE); - $criteria->addSelectColumn(LangPeer::CODE); - $criteria->addSelectColumn(LangPeer::LOCALE); - $criteria->addSelectColumn(LangPeer::URL); - $criteria->addSelectColumn(LangPeer::BY_DEFAULT); - $criteria->addSelectColumn(LangPeer::CREATED_AT); - $criteria->addSelectColumn(LangPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.url'); - $criteria->addSelectColumn($alias . '.by_default'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(LangPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - LangPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(LangPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Lang - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = LangPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return LangPeer::populateObjects(LangPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - LangPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(LangPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Lang $obj A Lang object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - LangPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Lang object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Lang) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Lang object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(LangPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Lang Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(LangPeer::$instances[$key])) { - return LangPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (LangPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - LangPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to lang - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = LangPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = LangPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = LangPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - LangPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Lang object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = LangPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = LangPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + LangPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = LangPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - LangPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(LangPeer::DATABASE_NAME)->getTable(LangPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseLangPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseLangPeer::TABLE_NAME)) { - $dbMap->addTableObject(new LangTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return LangPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Lang or Criteria object. - * - * @param mixed $values Criteria or Lang object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Lang object - } - - if ($criteria->containsKey(LangPeer::ID) && $criteria->keyContainsValue(LangPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.LangPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(LangPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Lang or Criteria object. - * - * @param mixed $values Criteria or Lang object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(LangPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(LangPeer::ID); - $value = $criteria->remove(LangPeer::ID); - if ($value) { - $selectCriteria->add(LangPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(LangPeer::TABLE_NAME); - } - - } else { // $values is Lang object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(LangPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the lang table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(LangPeer::TABLE_NAME, $con, LangPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - LangPeer::clearInstancePool(); - LangPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Lang or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Lang object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - LangPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Lang) { // it's a model object - // invalidate the cache for this single object - LangPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(LangPeer::DATABASE_NAME); - $criteria->add(LangPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - LangPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(LangPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - LangPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Lang object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Lang $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(LangPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(LangPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(LangPeer::DATABASE_NAME, LangPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Lang - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = LangPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(LangPeer::DATABASE_NAME); - $criteria->add(LangPeer::ID, $pk); - - $v = LangPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Lang[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(LangPeer::DATABASE_NAME); - $criteria->add(LangPeer::ID, $pks, Criteria::IN); - $objs = LangPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseLangPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseLangPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseLangQuery.php b/core/lib/Thelia/Model/om/BaseLangQuery.php deleted file mode 100755 index 10105802e..000000000 --- a/core/lib/Thelia/Model/om/BaseLangQuery.php +++ /dev/null @@ -1,622 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Lang|Lang[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = LangPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(LangPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Lang A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Lang A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `title`, `code`, `locale`, `url`, `by_default`, `created_at`, `updated_at` FROM `lang` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Lang(); - $obj->hydrate($row); - LangPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Lang|Lang[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Lang[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(LangPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(LangPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(LangPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(LangPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(LangPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(LangPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(LangPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(LangPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the url column - * - * Example usage: - * - * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' - * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' - * - * - * @param string $url The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByUrl($url = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($url)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $url)) { - $url = str_replace('*', '%', $url); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(LangPeer::URL, $url, $comparison); - } - - /** - * Filter the query on the by_default column - * - * Example usage: - * - * $query->filterByByDefault(1234); // WHERE by_default = 1234 - * $query->filterByByDefault(array(12, 34)); // WHERE by_default IN (12, 34) - * $query->filterByByDefault(array('min' => 12)); // WHERE by_default >= 12 - * $query->filterByByDefault(array('max' => 12)); // WHERE by_default <= 12 - * - * - * @param mixed $byDefault The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByByDefault($byDefault = null, $comparison = null) - { - if (is_array($byDefault)) { - $useMinMax = false; - if (isset($byDefault['min'])) { - $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($byDefault['max'])) { - $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(LangPeer::BY_DEFAULT, $byDefault, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(LangPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return LangQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(LangPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Exclude object from result - * - * @param Lang $lang Object to remove from the list of results - * - * @return LangQuery The current query, for fluid interface - */ - public function prune($lang = null) - { - if ($lang) { - $this->addUsingAlias(LangPeer::ID, $lang->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return LangQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(LangPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return LangQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(LangPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return LangQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(LangPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return LangQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(LangPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return LangQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(LangPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return LangQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(LangPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseMessage.php b/core/lib/Thelia/Model/om/BaseMessage.php deleted file mode 100755 index 09686a988..000000000 --- a/core/lib/Thelia/Model/om/BaseMessage.php +++ /dev/null @@ -1,2461 +0,0 @@ -version = 0; - } - - /** - * Initializes internal state of BaseMessage 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 Message The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = MessagePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Message The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = MessagePeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [secured] column. - * - * @param int $v new value - * @return Message The current object (for fluent API support) - */ - public function setSecured($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->secured !== $v) { - $this->secured = $v; - $this->modifiedColumns[] = MessagePeer::SECURED; - } - - - return $this; - } // setSecured() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return Message The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = MessagePeer::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 Message The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = MessagePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Message The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = MessagePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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. - * - * 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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 9; // 9 = MessagePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Message object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = MessagePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collMessageI18ns = null; - - $this->collMessageVersions = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = MessageQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - // 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 - if (!$this->isColumnModified(MessagePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(MessagePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(MessagePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - // versionable behavior - if (isset($createVersion)) { - $this->addVersion($con); - } - MessagePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->messageI18nsScheduledForDeletion !== null) { - if (!$this->messageI18nsScheduledForDeletion->isEmpty()) { - MessageI18nQuery::create() - ->filterByPrimaryKeys($this->messageI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->messageI18nsScheduledForDeletion = null; - } - } - - if ($this->collMessageI18ns !== null) { - foreach ($this->collMessageI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - 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() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = MessagePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . MessagePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(MessagePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(MessagePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(MessagePeer::SECURED)) { - $modifiedColumns[':p' . $index++] = '`secured`'; - } - if ($this->isColumnModified(MessagePeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; - } - if ($this->isColumnModified(MessagePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - 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)', - 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); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = MessagePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collMessageI18ns !== null) { - foreach ($this->collMessageI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collMessageVersions !== null) { - foreach ($this->collMessageVersions as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->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['Message'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Message'][$this->getPrimaryKey()] = true; - $keys = MessagePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->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->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; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = MessagePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->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 = MessagePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->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(MessagePeer::DATABASE_NAME); - - if ($this->isColumnModified(MessagePeer::ID)) $criteria->add(MessagePeer::ID, $this->id); - if ($this->isColumnModified(MessagePeer::CODE)) $criteria->add(MessagePeer::CODE, $this->code); - if ($this->isColumnModified(MessagePeer::SECURED)) $criteria->add(MessagePeer::SECURED, $this->secured); - 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; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(MessagePeer::DATABASE_NAME); - $criteria->add(MessagePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Message (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->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; - - foreach ($this->getMessageI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addMessageI18n($relObj->copy($deepCopy)); - } - } - - 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) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Message Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return MessagePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new MessagePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('MessageI18n' == $relationName) { - $this->initMessageI18ns(); - } - if ('MessageVersion' == $relationName) { - $this->initMessageVersions(); - } - } - - /** - * Clears out the collMessageI18ns 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 Message The current object (for fluent API support) - * @see addMessageI18ns() - */ - public function clearMessageI18ns() - { - $this->collMessageI18ns = null; // important to set this to null since that means it is uninitialized - $this->collMessageI18nsPartial = null; - - return $this; - } - - /** - * reset is the collMessageI18ns collection loaded partially - * - * @return void - */ - public function resetPartialMessageI18ns($v = true) - { - $this->collMessageI18nsPartial = $v; - } - - /** - * Initializes the collMessageI18ns collection. - * - * By default this just sets the collMessageI18ns collection to an empty array (like clearcollMessageI18ns()); - * 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 initMessageI18ns($overrideExisting = true) - { - if (null !== $this->collMessageI18ns && !$overrideExisting) { - return; - } - $this->collMessageI18ns = new PropelObjectCollection(); - $this->collMessageI18ns->setModel('MessageI18n'); - } - - /** - * Gets an array of MessageI18n 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|MessageI18n[] List of MessageI18n objects - * @throws PropelException - */ - public function getMessageI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collMessageI18nsPartial && !$this->isNew(); - if (null === $this->collMessageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collMessageI18ns) { - // return empty collection - $this->initMessageI18ns(); - } else { - $collMessageI18ns = MessageI18nQuery::create(null, $criteria) - ->filterByMessage($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collMessageI18nsPartial && count($collMessageI18ns)) { - $this->initMessageI18ns(false); - - foreach($collMessageI18ns as $obj) { - if (false == $this->collMessageI18ns->contains($obj)) { - $this->collMessageI18ns->append($obj); - } - } - - $this->collMessageI18nsPartial = true; - } - - $collMessageI18ns->getInternalIterator()->rewind(); - return $collMessageI18ns; - } - - if($partial && $this->collMessageI18ns) { - foreach($this->collMessageI18ns as $obj) { - if($obj->isNew()) { - $collMessageI18ns[] = $obj; - } - } - } - - $this->collMessageI18ns = $collMessageI18ns; - $this->collMessageI18nsPartial = false; - } - } - - return $this->collMessageI18ns; - } - - /** - * Sets a collection of MessageI18n 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 $messageI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Message The current object (for fluent API support) - */ - public function setMessageI18ns(PropelCollection $messageI18ns, PropelPDO $con = null) - { - $messageI18nsToDelete = $this->getMessageI18ns(new Criteria(), $con)->diff($messageI18ns); - - $this->messageI18nsScheduledForDeletion = unserialize(serialize($messageI18nsToDelete)); - - foreach ($messageI18nsToDelete as $messageI18nRemoved) { - $messageI18nRemoved->setMessage(null); - } - - $this->collMessageI18ns = null; - foreach ($messageI18ns as $messageI18n) { - $this->addMessageI18n($messageI18n); - } - - $this->collMessageI18ns = $messageI18ns; - $this->collMessageI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related MessageI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related MessageI18n objects. - * @throws PropelException - */ - public function countMessageI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collMessageI18nsPartial && !$this->isNew(); - if (null === $this->collMessageI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collMessageI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getMessageI18ns()); - } - $query = MessageI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByMessage($this) - ->count($con); - } - - return count($this->collMessageI18ns); - } - - /** - * Method called to associate a MessageI18n object to this object - * through the MessageI18n foreign key attribute. - * - * @param MessageI18n $l MessageI18n - * @return Message The current object (for fluent API support) - */ - public function addMessageI18n(MessageI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collMessageI18ns === null) { - $this->initMessageI18ns(); - $this->collMessageI18nsPartial = true; - } - if (!in_array($l, $this->collMessageI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddMessageI18n($l); - } - - return $this; - } - - /** - * @param MessageI18n $messageI18n The messageI18n object to add. - */ - protected function doAddMessageI18n($messageI18n) - { - $this->collMessageI18ns[]= $messageI18n; - $messageI18n->setMessage($this); - } - - /** - * @param MessageI18n $messageI18n The messageI18n object to remove. - * @return Message The current object (for fluent API support) - */ - public function removeMessageI18n($messageI18n) - { - if ($this->getMessageI18ns()->contains($messageI18n)) { - $this->collMessageI18ns->remove($this->collMessageI18ns->search($messageI18n)); - if (null === $this->messageI18nsScheduledForDeletion) { - $this->messageI18nsScheduledForDeletion = clone $this->collMessageI18ns; - $this->messageI18nsScheduledForDeletion->clear(); - } - $this->messageI18nsScheduledForDeletion[]= clone $messageI18n; - $messageI18n->setMessage(null); - } - - return $this; - } - - /** - * 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 Message The current object (for fluent API support) - * @see addMessageVersions() - */ - public function clearMessageVersions() - { - $this->collMessageVersions = null; // important to set this to null since that means it is uninitialized - $this->collMessageVersionsPartial = null; - - return $this; - } - - /** - * 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; - } - - $collMessageVersions->getInternalIterator()->rewind(); - 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 - * @return Message The current object (for fluent API support) - */ - public function setMessageVersions(PropelCollection $messageVersions, PropelPDO $con = null) - { - $messageVersionsToDelete = $this->getMessageVersions(new Criteria(), $con)->diff($messageVersions); - - $this->messageVersionsScheduledForDeletion = unserialize(serialize($messageVersionsToDelete)); - - foreach ($messageVersionsToDelete as $messageVersionRemoved) { - $messageVersionRemoved->setMessage(null); - } - - $this->collMessageVersions = null; - foreach ($messageVersions as $messageVersion) { - $this->addMessageVersion($messageVersion); - } - - $this->collMessageVersions = $messageVersions; - $this->collMessageVersionsPartial = false; - - return $this; - } - - /** - * 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; - } - - if($partial && !$criteria) { - return count($this->getMessageVersions()); - } - $query = MessageVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByMessage($this) - ->count($con); - } - - return count($this->collMessageVersions); - } - - /** - * 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 (!in_array($l, $this->collMessageVersions->getArrayCopy(), true)) { // 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. - * @return Message The current object (for fluent API support) - */ - 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[]= clone $messageVersion; - $messageVersion->setMessage(null); - } - - return $this; - } - - /** - * 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collMessageI18ns) { - foreach ($this->collMessageI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collMessageVersions) { - foreach ($this->collMessageVersions as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collMessageI18ns instanceof PropelCollection) { - $this->collMessageI18ns->clearIterator(); - } - $this->collMessageI18ns = null; - if ($this->collMessageVersions instanceof PropelCollection) { - $this->collMessageVersions->clearIterator(); - } - $this->collMessageVersions = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(MessagePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Message The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = MessagePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Message The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return MessageI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collMessageI18ns) { - foreach ($this->collMessageI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new MessageI18n(); - $translation->setLocale($locale); - } else { - $translation = MessageI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addMessageI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Message The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - MessageI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collMessageI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collMessageI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return MessageI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [description_html] column value. - * - * @return string - */ - public function getDescriptionHtml() - { - return $this->getCurrentTranslation()->getDescriptionHtml(); - } - - - /** - * Set the value of [description_html] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setDescriptionHtml($v) - { $this->getCurrentTranslation()->setDescriptionHtml($v); - - 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/BaseMessageI18n.php b/core/lib/Thelia/Model/om/BaseMessageI18n.php deleted file mode 100755 index 125134b75..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageI18n.php +++ /dev/null @@ -1,1132 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseMessageI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [description_html] column value. - * - * @return string - */ - public function getDescriptionHtml() - { - return $this->description_html; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = MessageI18nPeer::ID; - } - - if ($this->aMessage !== null && $this->aMessage->getId() !== $v) { - $this->aMessage = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = MessageI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = MessageI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = MessageI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [description_html] column. - * - * @param string $v new value - * @return MessageI18n The current object (for fluent API support) - */ - public function setDescriptionHtml($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description_html !== $v) { - $this->description_html = $v; - $this->modifiedColumns[] = MessageI18nPeer::DESCRIPTION_HTML; - } - - - return $this; - } // setDescriptionHtml() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->description_html = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 5; // 5 = MessageI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating MessageI18n 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(MessageI18nPeer::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 = MessageI18nPeer::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(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = MessageI18nQuery::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(MessageI18nPeer::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); - MessageI18nPeer::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(MessageI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(MessageI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(MessageI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION_HTML)) { - $modifiedColumns[':p' . $index++] = '`description_html`'; - } - - $sql = sprintf( - 'INSERT INTO `message_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`description_html`': - $stmt->bindValue($identifier, $this->description_html, PDO::PARAM_STR); - break; - } - } - $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; - } - - $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 = MessageI18nPeer::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 = MessageI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getDescriptionHtml(); - 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['MessageI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['MessageI18n'][serialize($this->getPrimaryKey())] = true; - $keys = MessageI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getDescriptionHtml(), - ); - 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 = MessageI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setDescriptionHtml($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 = MessageI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDescriptionHtml($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(MessageI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(MessageI18nPeer::ID)) $criteria->add(MessageI18nPeer::ID, $this->id); - if ($this->isColumnModified(MessageI18nPeer::LOCALE)) $criteria->add(MessageI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(MessageI18nPeer::TITLE)) $criteria->add(MessageI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION)) $criteria->add(MessageI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(MessageI18nPeer::DESCRIPTION_HTML)) $criteria->add(MessageI18nPeer::DESCRIPTION_HTML, $this->description_html); - - 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(MessageI18nPeer::DATABASE_NAME); - $criteria->add(MessageI18nPeer::ID, $this->id); - $criteria->add(MessageI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 MessageI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setDescriptionHtml($this->getDescriptionHtml()); - - 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 MessageI18n 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 MessageI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new MessageI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Message object. - * - * @param Message $v - * @return MessageI18n 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->addMessageI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Message object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Message The associated Message object. - * @throws PropelException - */ - public function getMessage(PropelPDO $con = null, $doQuery = true) - { - if ($this->aMessage === null && ($this->id !== null) && $doQuery) { - $this->aMessage = MessageQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->addMessageI18ns($this); - */ - } - - return $this->aMessage; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->description_html = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aMessage instanceof Persistent) { - $this->aMessage->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aMessage = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(MessageI18nPeer::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/BaseMessageI18nPeer.php b/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php deleted file mode 100755 index 6235fc484..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageI18nPeer.php +++ /dev/null @@ -1,1011 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'DescriptionHtml', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'descriptionHtml', ), - BasePeer::TYPE_COLNAME => array (MessageI18nPeer::ID, MessageI18nPeer::LOCALE, MessageI18nPeer::TITLE, MessageI18nPeer::DESCRIPTION, MessageI18nPeer::DESCRIPTION_HTML, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'DESCRIPTION_HTML', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'description_html', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. MessageI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'DescriptionHtml' => 4, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'descriptionHtml' => 4, ), - BasePeer::TYPE_COLNAME => array (MessageI18nPeer::ID => 0, MessageI18nPeer::LOCALE => 1, MessageI18nPeer::TITLE => 2, MessageI18nPeer::DESCRIPTION => 3, MessageI18nPeer::DESCRIPTION_HTML => 4, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'DESCRIPTION_HTML' => 4, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'description_html' => 4, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = MessageI18nPeer::getFieldNames($toType); - $key = isset(MessageI18nPeer::$fieldKeys[$fromType][$name]) ? MessageI18nPeer::$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(MessageI18nPeer::$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, MessageI18nPeer::$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 MessageI18nPeer::$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. MessageI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(MessageI18nPeer::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(MessageI18nPeer::ID); - $criteria->addSelectColumn(MessageI18nPeer::LOCALE); - $criteria->addSelectColumn(MessageI18nPeer::TITLE); - $criteria->addSelectColumn(MessageI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(MessageI18nPeer::DESCRIPTION_HTML); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.description_html'); - } - } - - /** - * 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(MessageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - MessageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(MessageI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(MessageI18nPeer::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 MessageI18n - * @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 = MessageI18nPeer::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 MessageI18nPeer::populateObjects(MessageI18nPeer::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 directly (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(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - MessageI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(MessageI18nPeer::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 MessageI18n $obj A MessageI18n 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->getLocale())); - } // if key === null - MessageI18nPeer::$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 MessageI18n 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 MessageI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 MessageI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(MessageI18nPeer::$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 MessageI18n 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(MessageI18nPeer::$instances[$key])) { - return MessageI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (MessageI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - MessageI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to message_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = MessageI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = MessageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = MessageI18nPeer::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; - MessageI18nPeer::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 (MessageI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = MessageI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = MessageI18nPeer::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 + MessageI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = MessageI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - MessageI18nPeer::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(MessageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - MessageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(MessageI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(MessageI18nPeer::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 MessageI18n 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 MessageI18n 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(MessageI18nPeer::DATABASE_NAME); - } - - MessageI18nPeer::addSelectColumns($criteria); - $startcol = MessageI18nPeer::NUM_HYDRATE_COLUMNS; - MessagePeer::addSelectColumns($criteria); - - $criteria->addJoin(MessageI18nPeer::ID, MessagePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = MessageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = MessageI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = MessageI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - MessageI18nPeer::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 (MessageI18n) to $obj2 (Message) - $obj2->addMessageI18n($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(MessageI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - MessageI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(MessageI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(MessageI18nPeer::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 MessageI18n 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 MessageI18n 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(MessageI18nPeer::DATABASE_NAME); - } - - MessageI18nPeer::addSelectColumns($criteria); - $startcol2 = MessageI18nPeer::NUM_HYDRATE_COLUMNS; - - MessagePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + MessagePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(MessageI18nPeer::ID, MessagePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = MessageI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = MessageI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = MessageI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - MessageI18nPeer::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 (MessageI18n) to the collection in $obj2 (Message) - $obj2->addMessageI18n($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(MessageI18nPeer::DATABASE_NAME)->getTable(MessageI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseMessageI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseMessageI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new MessageI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return MessageI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a MessageI18n or Criteria object. - * - * @param mixed $values Criteria or MessageI18n 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(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from MessageI18n object - } - - - // Set the correct dbName - $criteria->setDbName(MessageI18nPeer::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 MessageI18n or Criteria object. - * - * @param mixed $values Criteria or MessageI18n 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(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(MessageI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(MessageI18nPeer::ID); - $value = $criteria->remove(MessageI18nPeer::ID); - if ($value) { - $selectCriteria->add(MessageI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(MessageI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(MessageI18nPeer::LOCALE); - $value = $criteria->remove(MessageI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(MessageI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(MessageI18nPeer::TABLE_NAME); - } - - } else { // $values is MessageI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(MessageI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the message_i18n 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(MessageI18nPeer::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(MessageI18nPeer::TABLE_NAME, $con, MessageI18nPeer::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). - MessageI18nPeer::clearInstancePool(); - MessageI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a MessageI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or MessageI18n 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(MessageI18nPeer::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. - MessageI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof MessageI18n) { // it's a model object - // invalidate the cache for this single object - MessageI18nPeer::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(MessageI18nPeer::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(MessageI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(MessageI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - MessageI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(MessageI18nPeer::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); - MessageI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given MessageI18n 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 MessageI18n $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(MessageI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(MessageI18nPeer::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(MessageI18nPeer::DATABASE_NAME, MessageI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return MessageI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = MessageI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(MessageI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(MessageI18nPeer::DATABASE_NAME); - $criteria->add(MessageI18nPeer::ID, $id); - $criteria->add(MessageI18nPeer::LOCALE, $locale); - $v = MessageI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseMessageI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseMessageI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php b/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php deleted file mode 100755 index 8e584eece..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageI18nQuery.php +++ /dev/null @@ -1,504 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return MessageI18n|MessageI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = MessageI18nPeer::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(MessageI18nPeer::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 MessageI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `description_html` FROM `message_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 MessageI18n(); - $obj->hydrate($row); - MessageI18nPeer::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 MessageI18n|MessageI18n[]|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|MessageI18n[]|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 MessageI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(MessageI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(MessageI18nPeer::LOCALE, $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 MessageI18nQuery 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(MessageI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(MessageI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 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 MessageI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(MessageI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(MessageI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessageI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 MessageI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(MessageI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(MessageI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the description_html column - * - * Example usage: - * - * $query->filterByDescriptionHtml('fooValue'); // WHERE description_html = 'fooValue' - * $query->filterByDescriptionHtml('%fooValue%'); // WHERE description_html LIKE '%fooValue%' - * - * - * @param string $descriptionHtml The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageI18nQuery The current query, for fluid interface - */ - public function filterByDescriptionHtml($descriptionHtml = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($descriptionHtml)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $descriptionHtml)) { - $descriptionHtml = str_replace('*', '%', $descriptionHtml); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(MessageI18nPeer::DESCRIPTION_HTML, $descriptionHtml, $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 MessageI18nQuery 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(MessageI18nPeer::ID, $message->getId(), $comparison); - } elseif ($message instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(MessageI18nPeer::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 MessageI18nQuery The current query, for fluid interface - */ - public function joinMessage($relationAlias = null, $joinType = 'LEFT 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 = 'LEFT JOIN') - { - return $this - ->joinMessage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Message', '\Thelia\Model\MessageQuery'); - } - - /** - * Exclude object from result - * - * @param MessageI18n $messageI18n Object to remove from the list of results - * - * @return MessageI18nQuery The current query, for fluid interface - */ - public function prune($messageI18n = null) - { - if ($messageI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(MessageI18nPeer::ID), $messageI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(MessageI18nPeer::LOCALE), $messageI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseMessagePeer.php b/core/lib/Thelia/Model/om/BaseMessagePeer.php deleted file mode 100755 index fbb1e2966..000000000 --- a/core/lib/Thelia/Model/om/BaseMessagePeer.php +++ /dev/null @@ -1,860 +0,0 @@ - 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, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. MessagePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, '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, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = MessagePeer::getFieldNames($toType); - $key = isset(MessagePeer::$fieldKeys[$fromType][$name]) ? MessagePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(MessagePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, MessagePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return MessagePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. MessagePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(MessagePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(MessagePeer::ID); - $criteria->addSelectColumn(MessagePeer::CODE); - $criteria->addSelectColumn(MessagePeer::SECURED); - $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'); - $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(MessagePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - MessagePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(MessagePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Message - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = MessagePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return MessagePeer::populateObjects(MessagePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - MessagePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(MessagePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Message $obj A Message object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - MessagePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Message object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Message) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Message object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(MessagePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Message Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(MessagePeer::$instances[$key])) { - return MessagePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (MessagePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - MessagePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to message - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in 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(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = MessagePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = MessagePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = MessagePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - MessagePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Message object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = MessagePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = MessagePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + MessagePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = MessagePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - MessagePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(MessagePeer::DATABASE_NAME)->getTable(MessagePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseMessagePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseMessagePeer::TABLE_NAME)) { - $dbMap->addTableObject(new MessageTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return MessagePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Message or Criteria object. - * - * @param mixed $values Criteria or Message object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Message object - } - - if ($criteria->containsKey(MessagePeer::ID) && $criteria->keyContainsValue(MessagePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.MessagePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(MessagePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Message or Criteria object. - * - * @param mixed $values Criteria or Message object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(MessagePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(MessagePeer::ID); - $value = $criteria->remove(MessagePeer::ID); - if ($value) { - $selectCriteria->add(MessagePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(MessagePeer::TABLE_NAME); - } - - } else { // $values is Message object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(MessagePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the message table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(MessagePeer::TABLE_NAME, $con, MessagePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - MessagePeer::clearInstancePool(); - MessagePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Message or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Message object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - MessagePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Message) { // it's a model object - // invalidate the cache for this single object - MessagePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(MessagePeer::DATABASE_NAME); - $criteria->add(MessagePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - MessagePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(MessagePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - MessagePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Message object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Message $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(MessagePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(MessagePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(MessagePeer::DATABASE_NAME, MessagePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Message - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = MessagePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(MessagePeer::DATABASE_NAME); - $criteria->add(MessagePeer::ID, $pk); - - $v = MessagePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Message[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(MessagePeer::DATABASE_NAME); - $criteria->add(MessagePeer::ID, $pks, Criteria::IN); - $objs = MessagePeer::doSelect($criteria, $con); - } - - return $objs; - } - - // 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. -// -BaseMessagePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseMessageQuery.php b/core/lib/Thelia/Model/om/BaseMessageQuery.php deleted file mode 100755 index 036f52130..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageQuery.php +++ /dev/null @@ -1,899 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Message|Message[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = MessagePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(MessagePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Message A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Message A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `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); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Message(); - $obj->hydrate($row); - MessagePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Message|Message[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Message[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return MessageQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(MessagePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return MessageQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(MessagePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(MessagePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(MessagePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessagePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(MessagePeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the 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 - * $query->filterBySecured(array('max' => 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 MessageQuery 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(MessagePeer::SECURED, $secured['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($secured['max'])) { - $this->addUsingAlias(MessagePeer::SECURED, $secured['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessagePeer::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 MessageQuery 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(MessagePeer::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 MessageQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessagePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessagePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query 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 - * $query->filterByVersion(array('max' => 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 - * - * @param MessageI18n|PropelObjectCollection $messageI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return MessageQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByMessageI18n($messageI18n, $comparison = null) - { - if ($messageI18n instanceof MessageI18n) { - return $this - ->addUsingAlias(MessagePeer::ID, $messageI18n->getId(), $comparison); - } elseif ($messageI18n instanceof PropelObjectCollection) { - return $this - ->useMessageI18nQuery() - ->filterByPrimaryKeys($messageI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByMessageI18n() only accepts arguments of type MessageI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the MessageI18n 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 joinMessageI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('MessageI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'MessageI18n'); - } - - return $this; - } - - /** - * Use the MessageI18n relation MessageI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\MessageI18nQuery A secondary query class using the current class as primary query - */ - public function useMessageI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinMessageI18n($relationAlias, $joinType) - ->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 - * - * @param Message $message Object to remove from the list of results - * - * @return MessageQuery The current query, for fluid interface - */ - public function prune($message = null) - { - if ($message) { - $this->addUsingAlias(MessagePeer::ID, $message->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return MessageQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(MessagePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return MessageQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(MessagePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return MessageQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(MessagePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return MessageQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(MessagePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return MessageQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(MessagePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return MessageQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(MessagePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return MessageQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; - - return $this - ->joinMessageI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return MessageQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('MessageI18n'); - $this->with['MessageI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return MessageI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'MessageI18n', 'Thelia\Model\MessageI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseMessageVersion.php b/core/lib/Thelia/Model/om/BaseMessageVersion.php deleted file mode 100755 index 85d086827..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageVersion.php +++ /dev/null @@ -1,1450 +0,0 @@ -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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - 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; - } - - $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. - * @param $doQuery Executes a query to get the object if required - * @return Message The associated Message object. - * @throws PropelException - */ - public function getMessage(PropelPDO $con = null, $doQuery = true) - { - if ($this->aMessage === null && ($this->id !== null) && $doQuery) { - $this->aMessage = MessageQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aMessage instanceof Persistent) { - $this->aMessage->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // 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 deleted file mode 100755 index 32862e04e..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageVersionPeer.php +++ /dev/null @@ -1,1031 +0,0 @@ - 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 directly (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($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (MessageVersionPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - 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($row = 0, $colnum = 0) - { - 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 deleted file mode 100755 index fc7cbec0c..000000000 --- a/core/lib/Thelia/Model/om/BaseMessageVersionQuery.php +++ /dev/null @@ -1,704 +0,0 @@ -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 - * $query->filterById(array('max' => 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)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(MessageVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(MessageVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessageVersionPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterBySecured(array('max' => 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 - * $query->filterByVersion(array('max' => 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)) { - $useMinMax = false; - if (isset($version['min'])) { - $this->addUsingAlias(MessageVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($version['max'])) { - $this->addUsingAlias(MessageVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(MessageVersionPeer::VERSION, $version, $comparison); - } - - /** - * 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/BaseModule.php b/core/lib/Thelia/Model/om/BaseModule.php deleted file mode 100755 index e7d46a890..000000000 --- a/core/lib/Thelia/Model/om/BaseModule.php +++ /dev/null @@ -1,2030 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [type] column value. - * - * @return int - */ - public function getType() - { - return $this->type; - } - - /** - * Get the [activate] column value. - * - * @return int - */ - public function getActivate() - { - return $this->activate; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Module The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ModulePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Module The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = ModulePeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [type] column. - * - * @param int $v new value - * @return Module The current object (for fluent API support) - */ - public function setType($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->type !== $v) { - $this->type = $v; - $this->modifiedColumns[] = ModulePeer::TYPE; - } - - - return $this; - } // setType() - - /** - * Set the value of [activate] column. - * - * @param int $v new value - * @return Module The current object (for fluent API support) - */ - public function setActivate($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->activate !== $v) { - $this->activate = $v; - $this->modifiedColumns[] = ModulePeer::ACTIVATE; - } - - - return $this; - } // setActivate() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Module The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ModulePeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Module The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ModulePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Module The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ModulePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->type = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->activate = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->position = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = ModulePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Module object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ModulePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collGroupModules = null; - - $this->collModuleI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ModuleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ModulePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ModulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ModulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ModulePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->groupModulesScheduledForDeletion !== null) { - if (!$this->groupModulesScheduledForDeletion->isEmpty()) { - foreach ($this->groupModulesScheduledForDeletion as $groupModule) { - // need to save related object because we set the relation to null - $groupModule->save($con); - } - $this->groupModulesScheduledForDeletion = null; - } - } - - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->moduleI18nsScheduledForDeletion !== null) { - if (!$this->moduleI18nsScheduledForDeletion->isEmpty()) { - ModuleI18nQuery::create() - ->filterByPrimaryKeys($this->moduleI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->moduleI18nsScheduledForDeletion = null; - } - } - - if ($this->collModuleI18ns !== null) { - foreach ($this->collModuleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ModulePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ModulePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ModulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ModulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(ModulePeer::TYPE)) { - $modifiedColumns[':p' . $index++] = '`type`'; - } - if ($this->isColumnModified(ModulePeer::ACTIVATE)) { - $modifiedColumns[':p' . $index++] = '`activate`'; - } - if ($this->isColumnModified(ModulePeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(ModulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ModulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `module` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`type`': - $stmt->bindValue($identifier, $this->type, PDO::PARAM_INT); - break; - case '`activate`': - $stmt->bindValue($identifier, $this->activate, PDO::PARAM_INT); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = ModulePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collModuleI18ns !== null) { - foreach ($this->collModuleI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getType(); - break; - case 3: - return $this->getActivate(); - break; - case 4: - return $this->getPosition(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Module'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Module'][$this->getPrimaryKey()] = true; - $keys = ModulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getType(), - $keys[3] => $this->getActivate(), - $keys[4] => $this->getPosition(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collModuleI18ns) { - $result['ModuleI18ns'] = $this->collModuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ModulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setType($value); - break; - case 3: - $this->setActivate($value); - break; - case 4: - $this->setPosition($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ModulePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setActivate($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPosition($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - - if ($this->isColumnModified(ModulePeer::ID)) $criteria->add(ModulePeer::ID, $this->id); - if ($this->isColumnModified(ModulePeer::CODE)) $criteria->add(ModulePeer::CODE, $this->code); - if ($this->isColumnModified(ModulePeer::TYPE)) $criteria->add(ModulePeer::TYPE, $this->type); - if ($this->isColumnModified(ModulePeer::ACTIVATE)) $criteria->add(ModulePeer::ACTIVATE, $this->activate); - if ($this->isColumnModified(ModulePeer::POSITION)) $criteria->add(ModulePeer::POSITION, $this->position); - if ($this->isColumnModified(ModulePeer::CREATED_AT)) $criteria->add(ModulePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ModulePeer::UPDATED_AT)) $criteria->add(ModulePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - $criteria->add(ModulePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Module (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setType($this->getType()); - $copyObj->setActivate($this->getActivate()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getGroupModules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); - } - } - - foreach ($this->getModuleI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addModuleI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Module Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ModulePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ModulePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('GroupModule' == $relationName) { - $this->initGroupModules(); - } - if ('ModuleI18n' == $relationName) { - $this->initModuleI18ns(); - } - } - - /** - * Clears out the collGroupModules collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Module The current object (for fluent API support) - * @see addGroupModules() - */ - public function clearGroupModules() - { - $this->collGroupModules = null; // important to set this to null since that means it is uninitialized - $this->collGroupModulesPartial = null; - - return $this; - } - - /** - * reset is the collGroupModules collection loaded partially - * - * @return void - */ - public function resetPartialGroupModules($v = true) - { - $this->collGroupModulesPartial = $v; - } - - /** - * Initializes the collGroupModules collection. - * - * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupModules($overrideExisting = true) - { - if (null !== $this->collGroupModules && !$overrideExisting) { - return; - } - $this->collGroupModules = new PropelObjectCollection(); - $this->collGroupModules->setModel('GroupModule'); - } - - /** - * Gets an array of GroupModule objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Module is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupModule[] List of GroupModule objects - * @throws PropelException - */ - public function getGroupModules($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - // return empty collection - $this->initGroupModules(); - } else { - $collGroupModules = GroupModuleQuery::create(null, $criteria) - ->filterByModule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); - - foreach($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); - } - } - - $this->collGroupModulesPartial = true; - } - - $collGroupModules->getInternalIterator()->rewind(); - return $collGroupModules; - } - - if($partial && $this->collGroupModules) { - foreach($this->collGroupModules as $obj) { - if($obj->isNew()) { - $collGroupModules[] = $obj; - } - } - } - - $this->collGroupModules = $collGroupModules; - $this->collGroupModulesPartial = false; - } - } - - return $this->collGroupModules; - } - - /** - * Sets a collection of GroupModule objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $groupModules A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Module The current object (for fluent API support) - */ - public function setGroupModules(PropelCollection $groupModules, PropelPDO $con = null) - { - $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - - $this->groupModulesScheduledForDeletion = unserialize(serialize($groupModulesToDelete)); - - foreach ($groupModulesToDelete as $groupModuleRemoved) { - $groupModuleRemoved->setModule(null); - } - - $this->collGroupModules = null; - foreach ($groupModules as $groupModule) { - $this->addGroupModule($groupModule); - } - - $this->collGroupModules = $groupModules; - $this->collGroupModulesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupModule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupModule objects. - * @throws PropelException - */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getGroupModules()); - } - $query = GroupModuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByModule($this) - ->count($con); - } - - return count($this->collGroupModules); - } - - /** - * Method called to associate a GroupModule object to this object - * through the GroupModule foreign key attribute. - * - * @param GroupModule $l GroupModule - * @return Module The current object (for fluent API support) - */ - public function addGroupModule(GroupModule $l) - { - if ($this->collGroupModules === null) { - $this->initGroupModules(); - $this->collGroupModulesPartial = true; - } - if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupModule($l); - } - - return $this; - } - - /** - * @param GroupModule $groupModule The groupModule object to add. - */ - protected function doAddGroupModule($groupModule) - { - $this->collGroupModules[]= $groupModule; - $groupModule->setModule($this); - } - - /** - * @param GroupModule $groupModule The groupModule object to remove. - * @return Module The current object (for fluent API support) - */ - public function removeGroupModule($groupModule) - { - if ($this->getGroupModules()->contains($groupModule)) { - $this->collGroupModules->remove($this->collGroupModules->search($groupModule)); - if (null === $this->groupModulesScheduledForDeletion) { - $this->groupModulesScheduledForDeletion = clone $this->collGroupModules; - $this->groupModulesScheduledForDeletion->clear(); - } - $this->groupModulesScheduledForDeletion[]= $groupModule; - $groupModule->setModule(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Module is new, it will return - * an empty collection; or if this Module has previously - * been saved, it will retrieve related GroupModules from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Module. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|GroupModule[] List of GroupModule objects - */ - public function getGroupModulesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = GroupModuleQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); - - return $this->getGroupModules($query, $con); - } - - /** - * Clears out the collModuleI18ns 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 Module The current object (for fluent API support) - * @see addModuleI18ns() - */ - public function clearModuleI18ns() - { - $this->collModuleI18ns = null; // important to set this to null since that means it is uninitialized - $this->collModuleI18nsPartial = null; - - return $this; - } - - /** - * reset is the collModuleI18ns collection loaded partially - * - * @return void - */ - public function resetPartialModuleI18ns($v = true) - { - $this->collModuleI18nsPartial = $v; - } - - /** - * Initializes the collModuleI18ns collection. - * - * By default this just sets the collModuleI18ns collection to an empty array (like clearcollModuleI18ns()); - * 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 initModuleI18ns($overrideExisting = true) - { - if (null !== $this->collModuleI18ns && !$overrideExisting) { - return; - } - $this->collModuleI18ns = new PropelObjectCollection(); - $this->collModuleI18ns->setModel('ModuleI18n'); - } - - /** - * Gets an array of ModuleI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Module is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ModuleI18n[] List of ModuleI18n objects - * @throws PropelException - */ - public function getModuleI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collModuleI18nsPartial && !$this->isNew(); - if (null === $this->collModuleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collModuleI18ns) { - // return empty collection - $this->initModuleI18ns(); - } else { - $collModuleI18ns = ModuleI18nQuery::create(null, $criteria) - ->filterByModule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collModuleI18nsPartial && count($collModuleI18ns)) { - $this->initModuleI18ns(false); - - foreach($collModuleI18ns as $obj) { - if (false == $this->collModuleI18ns->contains($obj)) { - $this->collModuleI18ns->append($obj); - } - } - - $this->collModuleI18nsPartial = true; - } - - $collModuleI18ns->getInternalIterator()->rewind(); - return $collModuleI18ns; - } - - if($partial && $this->collModuleI18ns) { - foreach($this->collModuleI18ns as $obj) { - if($obj->isNew()) { - $collModuleI18ns[] = $obj; - } - } - } - - $this->collModuleI18ns = $collModuleI18ns; - $this->collModuleI18nsPartial = false; - } - } - - return $this->collModuleI18ns; - } - - /** - * Sets a collection of ModuleI18n 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 $moduleI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Module The current object (for fluent API support) - */ - public function setModuleI18ns(PropelCollection $moduleI18ns, PropelPDO $con = null) - { - $moduleI18nsToDelete = $this->getModuleI18ns(new Criteria(), $con)->diff($moduleI18ns); - - $this->moduleI18nsScheduledForDeletion = unserialize(serialize($moduleI18nsToDelete)); - - foreach ($moduleI18nsToDelete as $moduleI18nRemoved) { - $moduleI18nRemoved->setModule(null); - } - - $this->collModuleI18ns = null; - foreach ($moduleI18ns as $moduleI18n) { - $this->addModuleI18n($moduleI18n); - } - - $this->collModuleI18ns = $moduleI18ns; - $this->collModuleI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ModuleI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ModuleI18n objects. - * @throws PropelException - */ - public function countModuleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collModuleI18nsPartial && !$this->isNew(); - if (null === $this->collModuleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collModuleI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getModuleI18ns()); - } - $query = ModuleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByModule($this) - ->count($con); - } - - return count($this->collModuleI18ns); - } - - /** - * Method called to associate a ModuleI18n object to this object - * through the ModuleI18n foreign key attribute. - * - * @param ModuleI18n $l ModuleI18n - * @return Module The current object (for fluent API support) - */ - public function addModuleI18n(ModuleI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collModuleI18ns === null) { - $this->initModuleI18ns(); - $this->collModuleI18nsPartial = true; - } - if (!in_array($l, $this->collModuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddModuleI18n($l); - } - - return $this; - } - - /** - * @param ModuleI18n $moduleI18n The moduleI18n object to add. - */ - protected function doAddModuleI18n($moduleI18n) - { - $this->collModuleI18ns[]= $moduleI18n; - $moduleI18n->setModule($this); - } - - /** - * @param ModuleI18n $moduleI18n The moduleI18n object to remove. - * @return Module The current object (for fluent API support) - */ - public function removeModuleI18n($moduleI18n) - { - if ($this->getModuleI18ns()->contains($moduleI18n)) { - $this->collModuleI18ns->remove($this->collModuleI18ns->search($moduleI18n)); - if (null === $this->moduleI18nsScheduledForDeletion) { - $this->moduleI18nsScheduledForDeletion = clone $this->collModuleI18ns; - $this->moduleI18nsScheduledForDeletion->clear(); - } - $this->moduleI18nsScheduledForDeletion[]= clone $moduleI18n; - $moduleI18n->setModule(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->type = null; - $this->activate = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collModuleI18ns) { - foreach ($this->collModuleI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collGroupModules instanceof PropelCollection) { - $this->collGroupModules->clearIterator(); - } - $this->collGroupModules = null; - if ($this->collModuleI18ns instanceof PropelCollection) { - $this->collModuleI18ns->clearIterator(); - } - $this->collModuleI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ModulePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Module The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ModulePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Module The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ModuleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collModuleI18ns) { - foreach ($this->collModuleI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ModuleI18n(); - $translation->setLocale($locale); - } else { - $translation = ModuleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addModuleI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Module The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ModuleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collModuleI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collModuleI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ModuleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseModuleI18n.php b/core/lib/Thelia/Model/om/BaseModuleI18n.php deleted file mode 100755 index dbddaeeed..000000000 --- a/core/lib/Thelia/Model/om/BaseModuleI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseModuleI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ModuleI18nPeer::ID; - } - - if ($this->aModule !== null && $this->aModule->getId() !== $v) { - $this->aModule = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ModuleI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ModuleI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ModuleI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ModuleI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ModuleI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ModuleI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ModuleI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ModuleI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aModule !== null && $this->id !== $this->aModule->getId()) { - $this->aModule = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::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 = ModuleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aModule = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ModuleI18nQuery::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(ModuleI18nPeer::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); - ModuleI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aModule !== null) { - if ($this->aModule->isModified() || $this->aModule->isNew()) { - $affectedRows += $this->aModule->save($con); - } - $this->setModule($this->aModule); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ModuleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ModuleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ModuleI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ModuleI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ModuleI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ModuleI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `module_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aModule !== null) { - if (!$this->aModule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aModule->getValidationFailures()); - } - } - - - if (($retval = ModuleI18nPeer::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 = ModuleI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ModuleI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ModuleI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ModuleI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aModule) { - $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ModuleI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ModuleI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ModuleI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ModuleI18nPeer::ID)) $criteria->add(ModuleI18nPeer::ID, $this->id); - if ($this->isColumnModified(ModuleI18nPeer::LOCALE)) $criteria->add(ModuleI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ModuleI18nPeer::TITLE)) $criteria->add(ModuleI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ModuleI18nPeer::DESCRIPTION)) $criteria->add(ModuleI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ModuleI18nPeer::CHAPO)) $criteria->add(ModuleI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ModuleI18nPeer::POSTSCRIPTUM)) $criteria->add(ModuleI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ModuleI18nPeer::DATABASE_NAME); - $criteria->add(ModuleI18nPeer::ID, $this->id); - $criteria->add(ModuleI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ModuleI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ModuleI18n 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 ModuleI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ModuleI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Module object. - * - * @param Module $v - * @return ModuleI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setModule(Module $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aModule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Module object, it will not be re-added. - if ($v !== null) { - $v->addModuleI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Module object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Module The associated Module object. - * @throws PropelException - */ - public function getModule(PropelPDO $con = null, $doQuery = true) - { - if ($this->aModule === null && ($this->id !== null) && $doQuery) { - $this->aModule = ModuleQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aModule->addModuleI18ns($this); - */ - } - - return $this->aModule; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aModule instanceof Persistent) { - $this->aModule->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aModule = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ModuleI18nPeer::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/BaseModuleI18nPeer.php b/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php deleted file mode 100755 index 8493e7eae..000000000 --- a/core/lib/Thelia/Model/om/BaseModuleI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ModuleI18nPeer::ID, ModuleI18nPeer::LOCALE, ModuleI18nPeer::TITLE, ModuleI18nPeer::DESCRIPTION, ModuleI18nPeer::CHAPO, ModuleI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ModuleI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ModuleI18nPeer::ID => 0, ModuleI18nPeer::LOCALE => 1, ModuleI18nPeer::TITLE => 2, ModuleI18nPeer::DESCRIPTION => 3, ModuleI18nPeer::CHAPO => 4, ModuleI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ModuleI18nPeer::getFieldNames($toType); - $key = isset(ModuleI18nPeer::$fieldKeys[$fromType][$name]) ? ModuleI18nPeer::$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(ModuleI18nPeer::$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, ModuleI18nPeer::$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 ModuleI18nPeer::$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. ModuleI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ModuleI18nPeer::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(ModuleI18nPeer::ID); - $criteria->addSelectColumn(ModuleI18nPeer::LOCALE); - $criteria->addSelectColumn(ModuleI18nPeer::TITLE); - $criteria->addSelectColumn(ModuleI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ModuleI18nPeer::CHAPO); - $criteria->addSelectColumn(ModuleI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ModuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ModuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ModuleI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::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 ModuleI18n - * @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 = ModuleI18nPeer::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 ModuleI18nPeer::populateObjects(ModuleI18nPeer::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 directly (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(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ModuleI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ModuleI18nPeer::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 ModuleI18n $obj A ModuleI18n 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->getLocale())); - } // if key === null - ModuleI18nPeer::$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 ModuleI18n 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 ModuleI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ModuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ModuleI18nPeer::$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 ModuleI18n 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(ModuleI18nPeer::$instances[$key])) { - return ModuleI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ModuleI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ModuleI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to module_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ModuleI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ModuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ModuleI18nPeer::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; - ModuleI18nPeer::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 (ModuleI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ModuleI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ModuleI18nPeer::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 + ModuleI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ModuleI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ModuleI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Module table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinModule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ModuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ModuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ModuleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ModuleI18nPeer::ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ModuleI18n objects pre-filled with their Module objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ModuleI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinModule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ModuleI18nPeer::DATABASE_NAME); - } - - ModuleI18nPeer::addSelectColumns($criteria); - $startcol = ModuleI18nPeer::NUM_HYDRATE_COLUMNS; - ModulePeer::addSelectColumns($criteria); - - $criteria->addJoin(ModuleI18nPeer::ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ModuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ModuleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ModuleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ModuleI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ModulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ModulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ModulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ModuleI18n) to $obj2 (Module) - $obj2->addModuleI18n($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(ModuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ModuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ModuleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ModuleI18nPeer::ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ModuleI18n 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 ModuleI18n 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(ModuleI18nPeer::DATABASE_NAME); - } - - ModuleI18nPeer::addSelectColumns($criteria); - $startcol2 = ModuleI18nPeer::NUM_HYDRATE_COLUMNS; - - ModulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ModulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ModuleI18nPeer::ID, ModulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ModuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ModuleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ModuleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ModuleI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Module rows - - $key2 = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ModulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ModulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ModulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ModuleI18n) to the collection in $obj2 (Module) - $obj2->addModuleI18n($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(ModuleI18nPeer::DATABASE_NAME)->getTable(ModuleI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseModuleI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseModuleI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ModuleI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ModuleI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ModuleI18n or Criteria object. - * - * @param mixed $values Criteria or ModuleI18n 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(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ModuleI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ModuleI18nPeer::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 ModuleI18n or Criteria object. - * - * @param mixed $values Criteria or ModuleI18n 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(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ModuleI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ModuleI18nPeer::ID); - $value = $criteria->remove(ModuleI18nPeer::ID); - if ($value) { - $selectCriteria->add(ModuleI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ModuleI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ModuleI18nPeer::LOCALE); - $value = $criteria->remove(ModuleI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ModuleI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ModuleI18nPeer::TABLE_NAME); - } - - } else { // $values is ModuleI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ModuleI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the module_i18n 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(ModuleI18nPeer::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(ModuleI18nPeer::TABLE_NAME, $con, ModuleI18nPeer::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). - ModuleI18nPeer::clearInstancePool(); - ModuleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ModuleI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ModuleI18n 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(ModuleI18nPeer::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. - ModuleI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ModuleI18n) { // it's a model object - // invalidate the cache for this single object - ModuleI18nPeer::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(ModuleI18nPeer::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(ModuleI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ModuleI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ModuleI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ModuleI18nPeer::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); - ModuleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ModuleI18n 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 ModuleI18n $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(ModuleI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ModuleI18nPeer::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(ModuleI18nPeer::DATABASE_NAME, ModuleI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ModuleI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ModuleI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ModuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ModuleI18nPeer::DATABASE_NAME); - $criteria->add(ModuleI18nPeer::ID, $id); - $criteria->add(ModuleI18nPeer::LOCALE, $locale); - $v = ModuleI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseModuleI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseModuleI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php b/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php deleted file mode 100755 index ca75f0050..000000000 --- a/core/lib/Thelia/Model/om/BaseModuleI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ModuleI18n|ModuleI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ModuleI18nPeer::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(ModuleI18nPeer::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 ModuleI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `module_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ModuleI18n(); - $obj->hydrate($row); - ModuleI18nPeer::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 ModuleI18n|ModuleI18n[]|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|ModuleI18n[]|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 ModuleI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ModuleI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ModuleI18nPeer::LOCALE, $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 ModuleI18nQuery 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(ModuleI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ModuleI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByModule() - * - * @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 ModuleI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ModuleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ModuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ModuleI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModuleI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Module object - * - * @param Module|PropelObjectCollection $module The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByModule($module, $comparison = null) - { - if ($module instanceof Module) { - return $this - ->addUsingAlias(ModuleI18nPeer::ID, $module->getId(), $comparison); - } elseif ($module instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ModuleI18nPeer::ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByModule() only accepts arguments of type Module or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Module relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function joinModule($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Module'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Module'); - } - - return $this; - } - - /** - * Use the Module relation Module object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query - */ - public function useModuleQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); - } - - /** - * Exclude object from result - * - * @param ModuleI18n $moduleI18n Object to remove from the list of results - * - * @return ModuleI18nQuery The current query, for fluid interface - */ - public function prune($moduleI18n = null) - { - if ($moduleI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ModuleI18nPeer::ID), $moduleI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ModuleI18nPeer::LOCALE), $moduleI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseModulePeer.php b/core/lib/Thelia/Model/om/BaseModulePeer.php deleted file mode 100755 index 35a71fb9f..000000000 --- a/core/lib/Thelia/Model/om/BaseModulePeer.php +++ /dev/null @@ -1,815 +0,0 @@ - array ('Id', 'Code', 'Type', 'Activate', 'Position', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'type', 'activate', 'position', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ModulePeer::ID, ModulePeer::CODE, ModulePeer::TYPE, ModulePeer::ACTIVATE, ModulePeer::POSITION, ModulePeer::CREATED_AT, ModulePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'TYPE', 'ACTIVATE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'type', 'activate', 'position', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ModulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Type' => 2, 'Activate' => 3, 'Position' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (ModulePeer::ID => 0, ModulePeer::CODE => 1, ModulePeer::TYPE => 2, ModulePeer::ACTIVATE => 3, ModulePeer::POSITION => 4, ModulePeer::CREATED_AT => 5, ModulePeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'TYPE' => 2, 'ACTIVATE' => 3, 'POSITION' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'type' => 2, 'activate' => 3, 'position' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ModulePeer::getFieldNames($toType); - $key = isset(ModulePeer::$fieldKeys[$fromType][$name]) ? ModulePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ModulePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ModulePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ModulePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ModulePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ModulePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ModulePeer::ID); - $criteria->addSelectColumn(ModulePeer::CODE); - $criteria->addSelectColumn(ModulePeer::TYPE); - $criteria->addSelectColumn(ModulePeer::ACTIVATE); - $criteria->addSelectColumn(ModulePeer::POSITION); - $criteria->addSelectColumn(ModulePeer::CREATED_AT); - $criteria->addSelectColumn(ModulePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.type'); - $criteria->addSelectColumn($alias . '.activate'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ModulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ModulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ModulePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Module - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ModulePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ModulePeer::populateObjects(ModulePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ModulePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ModulePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Module $obj A Module object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ModulePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Module object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Module) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Module object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ModulePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Module Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ModulePeer::$instances[$key])) { - return ModulePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ModulePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ModulePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to module - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in GroupModulePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupModulePeer::clearInstancePool(); - // Invalidate objects in ModuleI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ModuleI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ModulePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ModulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ModulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ModulePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Module object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ModulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ModulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ModulePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ModulePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ModulePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ModulePeer::DATABASE_NAME)->getTable(ModulePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseModulePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseModulePeer::TABLE_NAME)) { - $dbMap->addTableObject(new ModuleTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ModulePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Module or Criteria object. - * - * @param mixed $values Criteria or Module object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Module object - } - - if ($criteria->containsKey(ModulePeer::ID) && $criteria->keyContainsValue(ModulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ModulePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ModulePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Module or Criteria object. - * - * @param mixed $values Criteria or Module object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ModulePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ModulePeer::ID); - $value = $criteria->remove(ModulePeer::ID); - if ($value) { - $selectCriteria->add(ModulePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ModulePeer::TABLE_NAME); - } - - } else { // $values is Module object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ModulePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the module table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ModulePeer::TABLE_NAME, $con, ModulePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ModulePeer::clearInstancePool(); - ModulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Module or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Module object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ModulePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Module) { // it's a model object - // invalidate the cache for this single object - ModulePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - $criteria->add(ModulePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ModulePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ModulePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ModulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Module object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Module $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ModulePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ModulePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ModulePeer::DATABASE_NAME, ModulePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Module - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ModulePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - $criteria->add(ModulePeer::ID, $pk); - - $v = ModulePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Module[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ModulePeer::DATABASE_NAME); - $criteria->add(ModulePeer::ID, $pks, Criteria::IN); - $objs = ModulePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseModulePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseModulePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseModuleQuery.php b/core/lib/Thelia/Model/om/BaseModuleQuery.php deleted file mode 100755 index 66b9225c7..000000000 --- a/core/lib/Thelia/Model/om/BaseModuleQuery.php +++ /dev/null @@ -1,832 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Module|Module[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ModulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ModulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Module A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Module A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `type`, `activate`, `position`, `created_at`, `updated_at` FROM `module` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Module(); - $obj->hydrate($row); - ModulePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Module|Module[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Module[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ModulePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ModulePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ModulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ModulePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ModulePeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the type column - * - * Example usage: - * - * $query->filterByType(1234); // WHERE type = 1234 - * $query->filterByType(array(12, 34)); // WHERE type IN (12, 34) - * $query->filterByType(array('min' => 12)); // WHERE type >= 12 - * $query->filterByType(array('max' => 12)); // WHERE type <= 12 - * - * - * @param mixed $type The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByType($type = null, $comparison = null) - { - if (is_array($type)) { - $useMinMax = false; - if (isset($type['min'])) { - $this->addUsingAlias(ModulePeer::TYPE, $type['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($type['max'])) { - $this->addUsingAlias(ModulePeer::TYPE, $type['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::TYPE, $type, $comparison); - } - - /** - * Filter the query on the activate column - * - * Example usage: - * - * $query->filterByActivate(1234); // WHERE activate = 1234 - * $query->filterByActivate(array(12, 34)); // WHERE activate IN (12, 34) - * $query->filterByActivate(array('min' => 12)); // WHERE activate >= 12 - * $query->filterByActivate(array('max' => 12)); // WHERE activate <= 12 - * - * - * @param mixed $activate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByActivate($activate = null, $comparison = null) - { - if (is_array($activate)) { - $useMinMax = false; - if (isset($activate['min'])) { - $this->addUsingAlias(ModulePeer::ACTIVATE, $activate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($activate['max'])) { - $this->addUsingAlias(ModulePeer::ACTIVATE, $activate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::ACTIVATE, $activate, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ModulePeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ModulePeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ModulePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related GroupModule object - * - * @param GroupModule|PropelObjectCollection $groupModule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroupModule($groupModule, $comparison = null) - { - if ($groupModule instanceof GroupModule) { - return $this - ->addUsingAlias(ModulePeer::ID, $groupModule->getModuleId(), $comparison); - } elseif ($groupModule instanceof PropelObjectCollection) { - return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type GroupModule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupModule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModuleQuery The current query, for fluid interface - */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupModule'); - } - - return $this; - } - - /** - * Use the GroupModule relation GroupModule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query - */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); - } - - /** - * Filter the query by a related ModuleI18n object - * - * @param ModuleI18n|PropelObjectCollection $moduleI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ModuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByModuleI18n($moduleI18n, $comparison = null) - { - if ($moduleI18n instanceof ModuleI18n) { - return $this - ->addUsingAlias(ModulePeer::ID, $moduleI18n->getId(), $comparison); - } elseif ($moduleI18n instanceof PropelObjectCollection) { - return $this - ->useModuleI18nQuery() - ->filterByPrimaryKeys($moduleI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByModuleI18n() only accepts arguments of type ModuleI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ModuleI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ModuleQuery The current query, for fluid interface - */ - public function joinModuleI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ModuleI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ModuleI18n'); - } - - return $this; - } - - /** - * Use the ModuleI18n relation ModuleI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ModuleI18nQuery A secondary query class using the current class as primary query - */ - public function useModuleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinModuleI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', '\Thelia\Model\ModuleI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Module $module Object to remove from the list of results - * - * @return ModuleQuery The current query, for fluid interface - */ - public function prune($module = null) - { - if ($module) { - $this->addUsingAlias(ModulePeer::ID, $module->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ModuleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ModulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ModuleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ModulePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ModuleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ModulePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ModuleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ModulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ModuleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ModulePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ModuleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ModulePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ModuleQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; - - return $this - ->joinModuleI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ModuleQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ModuleI18n'); - $this->with['ModuleI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ModuleI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ModuleI18n', 'Thelia\Model\ModuleI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrder.php b/core/lib/Thelia/Model/om/BaseOrder.php deleted file mode 100755 index 9f3c72e34..000000000 --- a/core/lib/Thelia/Model/om/BaseOrder.php +++ /dev/null @@ -1,2868 +0,0 @@ -id; - } - - /** - * Get the [ref] column value. - * - * @return string - */ - public function getRef() - { - return $this->ref; - } - - /** - * Get the [customer_id] column value. - * - * @return int - */ - public function getCustomerId() - { - return $this->customer_id; - } - - /** - * Get the [address_invoice] column value. - * - * @return int - */ - public function getAddressInvoice() - { - return $this->address_invoice; - } - - /** - * Get the [address_delivery] column value. - * - * @return int - */ - public function getAddressDelivery() - { - return $this->address_delivery; - } - - /** - * Get the [optionally formatted] temporal [invoice_date] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getInvoiceDate($format = '%x') - { - if ($this->invoice_date === null) { - return null; - } - - if ($this->invoice_date === '0000-00-00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - try { - $dt = new DateTime($this->invoice_date); - } catch (Exception $x) { - throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->invoice_date, true), $x); - } - - if ($format === null) { - // Because propel.useDateTimeClass is true, we return a DateTime object. - return $dt; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Get the [currency_id] column value. - * - * @return int - */ - public function getCurrencyId() - { - return $this->currency_id; - } - - /** - * Get the [currency_rate] column value. - * - * @return double - */ - public function getCurrencyRate() - { - return $this->currency_rate; - } - - /** - * Get the [transaction] column value. - * - * @return string - */ - public function getTransaction() - { - return $this->transaction; - } - - /** - * Get the [delivery_num] column value. - * - * @return string - */ - public function getDeliveryNum() - { - return $this->delivery_num; - } - - /** - * Get the [invoice] column value. - * - * @return string - */ - public function getInvoice() - { - return $this->invoice; - } - - /** - * Get the [postage] column value. - * - * @return double - */ - public function getPostage() - { - return $this->postage; - } - - /** - * Get the [payment] column value. - * - * @return string - */ - public function getPayment() - { - return $this->payment; - } - - /** - * Get the [carrier] column value. - * - * @return string - */ - public function getCarrier() - { - return $this->carrier; - } - - /** - * Get the [status_id] column value. - * - * @return int - */ - public function getStatusId() - { - return $this->status_id; - } - - /** - * Get the [lang] column value. - * - * @return string - */ - public function getLang() - { - return $this->lang; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = OrderPeer::REF; - } - - - return $this; - } // setRef() - - /** - * Set the value of [customer_id] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setCustomerId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->customer_id !== $v) { - $this->customer_id = $v; - $this->modifiedColumns[] = OrderPeer::CUSTOMER_ID; - } - - if ($this->aCustomer !== null && $this->aCustomer->getId() !== $v) { - $this->aCustomer = null; - } - - - return $this; - } // setCustomerId() - - /** - * Set the value of [address_invoice] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setAddressInvoice($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->address_invoice !== $v) { - $this->address_invoice = $v; - $this->modifiedColumns[] = OrderPeer::ADDRESS_INVOICE; - } - - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->aOrderAddressRelatedByAddressInvoice->getId() !== $v) { - $this->aOrderAddressRelatedByAddressInvoice = null; - } - - - return $this; - } // setAddressInvoice() - - /** - * Set the value of [address_delivery] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setAddressDelivery($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->address_delivery !== $v) { - $this->address_delivery = $v; - $this->modifiedColumns[] = OrderPeer::ADDRESS_DELIVERY; - } - - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->aOrderAddressRelatedByAddressDelivery->getId() !== $v) { - $this->aOrderAddressRelatedByAddressDelivery = null; - } - - - return $this; - } // setAddressDelivery() - - /** - * Sets the value of [invoice_date] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Order The current object (for fluent API support) - */ - public function setInvoiceDate($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->invoice_date !== null || $dt !== null) { - $currentDateAsString = ($this->invoice_date !== null && $tmpDt = new DateTime($this->invoice_date)) ? $tmpDt->format('Y-m-d') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->invoice_date = $newDateAsString; - $this->modifiedColumns[] = OrderPeer::INVOICE_DATE; - } - } // if either are not null - - - return $this; - } // setInvoiceDate() - - /** - * Set the value of [currency_id] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setCurrencyId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->currency_id !== $v) { - $this->currency_id = $v; - $this->modifiedColumns[] = OrderPeer::CURRENCY_ID; - } - - if ($this->aCurrency !== null && $this->aCurrency->getId() !== $v) { - $this->aCurrency = null; - } - - - return $this; - } // setCurrencyId() - - /** - * Set the value of [currency_rate] column. - * - * @param double $v new value - * @return Order The current object (for fluent API support) - */ - public function setCurrencyRate($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->currency_rate !== $v) { - $this->currency_rate = $v; - $this->modifiedColumns[] = OrderPeer::CURRENCY_RATE; - } - - - return $this; - } // setCurrencyRate() - - /** - * Set the value of [transaction] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setTransaction($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->transaction !== $v) { - $this->transaction = $v; - $this->modifiedColumns[] = OrderPeer::TRANSACTION; - } - - - return $this; - } // setTransaction() - - /** - * Set the value of [delivery_num] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setDeliveryNum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->delivery_num !== $v) { - $this->delivery_num = $v; - $this->modifiedColumns[] = OrderPeer::DELIVERY_NUM; - } - - - return $this; - } // setDeliveryNum() - - /** - * Set the value of [invoice] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setInvoice($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->invoice !== $v) { - $this->invoice = $v; - $this->modifiedColumns[] = OrderPeer::INVOICE; - } - - - return $this; - } // setInvoice() - - /** - * Set the value of [postage] column. - * - * @param double $v new value - * @return Order The current object (for fluent API support) - */ - public function setPostage($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->postage !== $v) { - $this->postage = $v; - $this->modifiedColumns[] = OrderPeer::POSTAGE; - } - - - return $this; - } // setPostage() - - /** - * Set the value of [payment] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setPayment($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->payment !== $v) { - $this->payment = $v; - $this->modifiedColumns[] = OrderPeer::PAYMENT; - } - - - return $this; - } // setPayment() - - /** - * Set the value of [carrier] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setCarrier($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->carrier !== $v) { - $this->carrier = $v; - $this->modifiedColumns[] = OrderPeer::CARRIER; - } - - - return $this; - } // setCarrier() - - /** - * Set the value of [status_id] column. - * - * @param int $v new value - * @return Order The current object (for fluent API support) - */ - public function setStatusId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->status_id !== $v) { - $this->status_id = $v; - $this->modifiedColumns[] = OrderPeer::STATUS_ID; - } - - if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) { - $this->aOrderStatus = null; - } - - - return $this; - } // setStatusId() - - /** - * Set the value of [lang] column. - * - * @param string $v new value - * @return Order The current object (for fluent API support) - */ - public function setLang($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lang !== $v) { - $this->lang = $v; - $this->modifiedColumns[] = OrderPeer::LANG; - } - - - return $this; - } // setLang() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Order The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = OrderPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Order The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = OrderPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->ref = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->customer_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->address_invoice = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->address_delivery = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->invoice_date = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->currency_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null; - $this->currency_rate = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null; - $this->transaction = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->delivery_num = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->invoice = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->postage = ($row[$startcol + 11] !== null) ? (double) $row[$startcol + 11] : null; - $this->payment = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->carrier = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->status_id = ($row[$startcol + 14] !== null) ? (int) $row[$startcol + 14] : null; - $this->lang = ($row[$startcol + 15] !== null) ? (string) $row[$startcol + 15] : null; - $this->created_at = ($row[$startcol + 16] !== null) ? (string) $row[$startcol + 16] : null; - $this->updated_at = ($row[$startcol + 17] !== null) ? (string) $row[$startcol + 17] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 18; // 18 = OrderPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Order object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCustomer !== null && $this->customer_id !== $this->aCustomer->getId()) { - $this->aCustomer = null; - } - if ($this->aOrderAddressRelatedByAddressInvoice !== null && $this->address_invoice !== $this->aOrderAddressRelatedByAddressInvoice->getId()) { - $this->aOrderAddressRelatedByAddressInvoice = null; - } - if ($this->aOrderAddressRelatedByAddressDelivery !== null && $this->address_delivery !== $this->aOrderAddressRelatedByAddressDelivery->getId()) { - $this->aOrderAddressRelatedByAddressDelivery = null; - } - if ($this->aCurrency !== null && $this->currency_id !== $this->aCurrency->getId()) { - $this->aCurrency = null; - } - if ($this->aOrderStatus !== null && $this->status_id !== $this->aOrderStatus->getId()) { - $this->aOrderStatus = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = OrderPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCurrency = null; - $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; - $this->aOrderStatus = null; - $this->collOrderProducts = null; - - $this->collCouponOrders = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCurrency !== null) { - if ($this->aCurrency->isModified() || $this->aCurrency->isNew()) { - $affectedRows += $this->aCurrency->save($con); - } - $this->setCurrency($this->aCurrency); - } - - if ($this->aCustomer !== null) { - if ($this->aCustomer->isModified() || $this->aCustomer->isNew()) { - $affectedRows += $this->aCustomer->save($con); - } - $this->setCustomer($this->aCustomer); - } - - if ($this->aOrderAddressRelatedByAddressInvoice !== null) { - if ($this->aOrderAddressRelatedByAddressInvoice->isModified() || $this->aOrderAddressRelatedByAddressInvoice->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressInvoice->save($con); - } - $this->setOrderAddressRelatedByAddressInvoice($this->aOrderAddressRelatedByAddressInvoice); - } - - if ($this->aOrderAddressRelatedByAddressDelivery !== null) { - if ($this->aOrderAddressRelatedByAddressDelivery->isModified() || $this->aOrderAddressRelatedByAddressDelivery->isNew()) { - $affectedRows += $this->aOrderAddressRelatedByAddressDelivery->save($con); - } - $this->setOrderAddressRelatedByAddressDelivery($this->aOrderAddressRelatedByAddressDelivery); - } - - if ($this->aOrderStatus !== null) { - if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) { - $affectedRows += $this->aOrderStatus->save($con); - } - $this->setOrderStatus($this->aOrderStatus); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->orderProductsScheduledForDeletion !== null) { - if (!$this->orderProductsScheduledForDeletion->isEmpty()) { - OrderProductQuery::create() - ->filterByPrimaryKeys($this->orderProductsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->orderProductsScheduledForDeletion = null; - } - } - - if ($this->collOrderProducts !== null) { - foreach ($this->collOrderProducts as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->couponOrdersScheduledForDeletion !== null) { - if (!$this->couponOrdersScheduledForDeletion->isEmpty()) { - CouponOrderQuery::create() - ->filterByPrimaryKeys($this->couponOrdersScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->couponOrdersScheduledForDeletion = null; - } - } - - if ($this->collCouponOrders !== null) { - foreach ($this->collCouponOrders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; - } - if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_id`'; - } - if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) { - $modifiedColumns[':p' . $index++] = '`address_invoice`'; - } - if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) { - $modifiedColumns[':p' . $index++] = '`address_delivery`'; - } - if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) { - $modifiedColumns[':p' . $index++] = '`invoice_date`'; - } - if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) { - $modifiedColumns[':p' . $index++] = '`currency_id`'; - } - if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) { - $modifiedColumns[':p' . $index++] = '`currency_rate`'; - } - if ($this->isColumnModified(OrderPeer::TRANSACTION)) { - $modifiedColumns[':p' . $index++] = '`transaction`'; - } - if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) { - $modifiedColumns[':p' . $index++] = '`delivery_num`'; - } - if ($this->isColumnModified(OrderPeer::INVOICE)) { - $modifiedColumns[':p' . $index++] = '`invoice`'; - } - if ($this->isColumnModified(OrderPeer::POSTAGE)) { - $modifiedColumns[':p' . $index++] = '`postage`'; - } - if ($this->isColumnModified(OrderPeer::PAYMENT)) { - $modifiedColumns[':p' . $index++] = '`payment`'; - } - if ($this->isColumnModified(OrderPeer::CARRIER)) { - $modifiedColumns[':p' . $index++] = '`carrier`'; - } - if ($this->isColumnModified(OrderPeer::STATUS_ID)) { - $modifiedColumns[':p' . $index++] = '`status_id`'; - } - if ($this->isColumnModified(OrderPeer::LANG)) { - $modifiedColumns[':p' . $index++] = '`lang`'; - } - if ($this->isColumnModified(OrderPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(OrderPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `order` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`ref`': - $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); - break; - case '`customer_id`': - $stmt->bindValue($identifier, $this->customer_id, PDO::PARAM_INT); - break; - case '`address_invoice`': - $stmt->bindValue($identifier, $this->address_invoice, PDO::PARAM_INT); - break; - case '`address_delivery`': - $stmt->bindValue($identifier, $this->address_delivery, PDO::PARAM_INT); - break; - case '`invoice_date`': - $stmt->bindValue($identifier, $this->invoice_date, PDO::PARAM_STR); - break; - case '`currency_id`': - $stmt->bindValue($identifier, $this->currency_id, PDO::PARAM_INT); - break; - case '`currency_rate`': - $stmt->bindValue($identifier, $this->currency_rate, PDO::PARAM_STR); - break; - case '`transaction`': - $stmt->bindValue($identifier, $this->transaction, PDO::PARAM_STR); - break; - case '`delivery_num`': - $stmt->bindValue($identifier, $this->delivery_num, PDO::PARAM_STR); - break; - case '`invoice`': - $stmt->bindValue($identifier, $this->invoice, PDO::PARAM_STR); - break; - case '`postage`': - $stmt->bindValue($identifier, $this->postage, PDO::PARAM_STR); - break; - case '`payment`': - $stmt->bindValue($identifier, $this->payment, PDO::PARAM_STR); - break; - case '`carrier`': - $stmt->bindValue($identifier, $this->carrier, PDO::PARAM_STR); - break; - case '`status_id`': - $stmt->bindValue($identifier, $this->status_id, PDO::PARAM_INT); - break; - case '`lang`': - $stmt->bindValue($identifier, $this->lang, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCurrency !== null) { - if (!$this->aCurrency->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCurrency->getValidationFailures()); - } - } - - if ($this->aCustomer !== null) { - if (!$this->aCustomer->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCustomer->getValidationFailures()); - } - } - - if ($this->aOrderAddressRelatedByAddressInvoice !== null) { - if (!$this->aOrderAddressRelatedByAddressInvoice->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrderAddressRelatedByAddressInvoice->getValidationFailures()); - } - } - - if ($this->aOrderAddressRelatedByAddressDelivery !== null) { - if (!$this->aOrderAddressRelatedByAddressDelivery->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrderAddressRelatedByAddressDelivery->getValidationFailures()); - } - } - - if ($this->aOrderStatus !== null) { - if (!$this->aOrderStatus->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrderStatus->getValidationFailures()); - } - } - - - if (($retval = OrderPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collOrderProducts !== null) { - foreach ($this->collOrderProducts as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collCouponOrders !== null) { - foreach ($this->collCouponOrders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getRef(); - break; - case 2: - return $this->getCustomerId(); - break; - case 3: - return $this->getAddressInvoice(); - break; - case 4: - return $this->getAddressDelivery(); - break; - case 5: - return $this->getInvoiceDate(); - break; - case 6: - return $this->getCurrencyId(); - break; - case 7: - return $this->getCurrencyRate(); - break; - case 8: - return $this->getTransaction(); - break; - case 9: - return $this->getDeliveryNum(); - break; - case 10: - return $this->getInvoice(); - break; - case 11: - return $this->getPostage(); - break; - case 12: - return $this->getPayment(); - break; - case 13: - return $this->getCarrier(); - break; - case 14: - return $this->getStatusId(); - break; - case 15: - return $this->getLang(); - break; - case 16: - return $this->getCreatedAt(); - break; - case 17: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Order'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Order'][$this->getPrimaryKey()] = true; - $keys = OrderPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getRef(), - $keys[2] => $this->getCustomerId(), - $keys[3] => $this->getAddressInvoice(), - $keys[4] => $this->getAddressDelivery(), - $keys[5] => $this->getInvoiceDate(), - $keys[6] => $this->getCurrencyId(), - $keys[7] => $this->getCurrencyRate(), - $keys[8] => $this->getTransaction(), - $keys[9] => $this->getDeliveryNum(), - $keys[10] => $this->getInvoice(), - $keys[11] => $this->getPostage(), - $keys[12] => $this->getPayment(), - $keys[13] => $this->getCarrier(), - $keys[14] => $this->getStatusId(), - $keys[15] => $this->getLang(), - $keys[16] => $this->getCreatedAt(), - $keys[17] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCurrency) { - $result['Currency'] = $this->aCurrency->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCustomer) { - $result['Customer'] = $this->aCustomer->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aOrderAddressRelatedByAddressInvoice) { - $result['OrderAddressRelatedByAddressInvoice'] = $this->aOrderAddressRelatedByAddressInvoice->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aOrderAddressRelatedByAddressDelivery) { - $result['OrderAddressRelatedByAddressDelivery'] = $this->aOrderAddressRelatedByAddressDelivery->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aOrderStatus) { - $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collOrderProducts) { - $result['OrderProducts'] = $this->collOrderProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collCouponOrders) { - $result['CouponOrders'] = $this->collCouponOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setRef($value); - break; - case 2: - $this->setCustomerId($value); - break; - case 3: - $this->setAddressInvoice($value); - break; - case 4: - $this->setAddressDelivery($value); - break; - case 5: - $this->setInvoiceDate($value); - break; - case 6: - $this->setCurrencyId($value); - break; - case 7: - $this->setCurrencyRate($value); - break; - case 8: - $this->setTransaction($value); - break; - case 9: - $this->setDeliveryNum($value); - break; - case 10: - $this->setInvoice($value); - break; - case 11: - $this->setPostage($value); - break; - case 12: - $this->setPayment($value); - break; - case 13: - $this->setCarrier($value); - break; - case 14: - $this->setStatusId($value); - break; - case 15: - $this->setLang($value); - break; - case 16: - $this->setCreatedAt($value); - break; - case 17: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = OrderPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setRef($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCustomerId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAddressInvoice($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setAddressDelivery($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setInvoiceDate($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCurrencyId($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCurrencyRate($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTransaction($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setDeliveryNum($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setInvoice($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setPostage($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setPayment($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setCarrier($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setStatusId($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setLang($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setUpdatedAt($arr[$keys[17]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderPeer::ID)) $criteria->add(OrderPeer::ID, $this->id); - if ($this->isColumnModified(OrderPeer::REF)) $criteria->add(OrderPeer::REF, $this->ref); - if ($this->isColumnModified(OrderPeer::CUSTOMER_ID)) $criteria->add(OrderPeer::CUSTOMER_ID, $this->customer_id); - if ($this->isColumnModified(OrderPeer::ADDRESS_INVOICE)) $criteria->add(OrderPeer::ADDRESS_INVOICE, $this->address_invoice); - if ($this->isColumnModified(OrderPeer::ADDRESS_DELIVERY)) $criteria->add(OrderPeer::ADDRESS_DELIVERY, $this->address_delivery); - if ($this->isColumnModified(OrderPeer::INVOICE_DATE)) $criteria->add(OrderPeer::INVOICE_DATE, $this->invoice_date); - if ($this->isColumnModified(OrderPeer::CURRENCY_ID)) $criteria->add(OrderPeer::CURRENCY_ID, $this->currency_id); - if ($this->isColumnModified(OrderPeer::CURRENCY_RATE)) $criteria->add(OrderPeer::CURRENCY_RATE, $this->currency_rate); - if ($this->isColumnModified(OrderPeer::TRANSACTION)) $criteria->add(OrderPeer::TRANSACTION, $this->transaction); - if ($this->isColumnModified(OrderPeer::DELIVERY_NUM)) $criteria->add(OrderPeer::DELIVERY_NUM, $this->delivery_num); - if ($this->isColumnModified(OrderPeer::INVOICE)) $criteria->add(OrderPeer::INVOICE, $this->invoice); - if ($this->isColumnModified(OrderPeer::POSTAGE)) $criteria->add(OrderPeer::POSTAGE, $this->postage); - if ($this->isColumnModified(OrderPeer::PAYMENT)) $criteria->add(OrderPeer::PAYMENT, $this->payment); - if ($this->isColumnModified(OrderPeer::CARRIER)) $criteria->add(OrderPeer::CARRIER, $this->carrier); - if ($this->isColumnModified(OrderPeer::STATUS_ID)) $criteria->add(OrderPeer::STATUS_ID, $this->status_id); - if ($this->isColumnModified(OrderPeer::LANG)) $criteria->add(OrderPeer::LANG, $this->lang); - if ($this->isColumnModified(OrderPeer::CREATED_AT)) $criteria->add(OrderPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderPeer::UPDATED_AT)) $criteria->add(OrderPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - $criteria->add(OrderPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Order (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setRef($this->getRef()); - $copyObj->setCustomerId($this->getCustomerId()); - $copyObj->setAddressInvoice($this->getAddressInvoice()); - $copyObj->setAddressDelivery($this->getAddressDelivery()); - $copyObj->setInvoiceDate($this->getInvoiceDate()); - $copyObj->setCurrencyId($this->getCurrencyId()); - $copyObj->setCurrencyRate($this->getCurrencyRate()); - $copyObj->setTransaction($this->getTransaction()); - $copyObj->setDeliveryNum($this->getDeliveryNum()); - $copyObj->setInvoice($this->getInvoice()); - $copyObj->setPostage($this->getPostage()); - $copyObj->setPayment($this->getPayment()); - $copyObj->setCarrier($this->getCarrier()); - $copyObj->setStatusId($this->getStatusId()); - $copyObj->setLang($this->getLang()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getOrderProducts() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderProduct($relObj->copy($deepCopy)); - } - } - - foreach ($this->getCouponOrders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addCouponOrder($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Order Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return OrderPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Currency object. - * - * @param Currency $v - * @return Order The current object (for fluent API support) - * @throws PropelException - */ - public function setCurrency(Currency $v = null) - { - if ($v === null) { - $this->setCurrencyId(NULL); - } else { - $this->setCurrencyId($v->getId()); - } - - $this->aCurrency = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Currency object, it will not be re-added. - if ($v !== null) { - $v->addOrder($this); - } - - - return $this; - } - - - /** - * Get the associated Currency object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Currency The associated Currency object. - * @throws PropelException - */ - public function getCurrency(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCurrency === null && ($this->currency_id !== null) && $doQuery) { - $this->aCurrency = CurrencyQuery::create()->findPk($this->currency_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCurrency->addOrders($this); - */ - } - - return $this->aCurrency; - } - - /** - * Declares an association between this object and a Customer object. - * - * @param Customer $v - * @return Order The current object (for fluent API support) - * @throws PropelException - */ - public function setCustomer(Customer $v = null) - { - if ($v === null) { - $this->setCustomerId(NULL); - } else { - $this->setCustomerId($v->getId()); - } - - $this->aCustomer = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Customer object, it will not be re-added. - if ($v !== null) { - $v->addOrder($this); - } - - - return $this; - } - - - /** - * Get the associated Customer object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Customer The associated Customer object. - * @throws PropelException - */ - public function getCustomer(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCustomer === null && ($this->customer_id !== null) && $doQuery) { - $this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCustomer->addOrders($this); - */ - } - - return $this->aCustomer; - } - - /** - * Declares an association between this object and a OrderAddress object. - * - * @param OrderAddress $v - * @return Order The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderAddressRelatedByAddressInvoice(OrderAddress $v = null) - { - if ($v === null) { - $this->setAddressInvoice(NULL); - } else { - $this->setAddressInvoice($v->getId()); - } - - $this->aOrderAddressRelatedByAddressInvoice = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the OrderAddress object, it will not be re-added. - if ($v !== null) { - $v->addOrderRelatedByAddressInvoice($this); - } - - - return $this; - } - - - /** - * Get the associated OrderAddress object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderAddress The associated OrderAddress object. - * @throws PropelException - */ - public function getOrderAddressRelatedByAddressInvoice(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrderAddressRelatedByAddressInvoice === null && ($this->address_invoice !== null) && $doQuery) { - $this->aOrderAddressRelatedByAddressInvoice = OrderAddressQuery::create()->findPk($this->address_invoice, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderAddressRelatedByAddressInvoice->addOrdersRelatedByAddressInvoice($this); - */ - } - - return $this->aOrderAddressRelatedByAddressInvoice; - } - - /** - * Declares an association between this object and a OrderAddress object. - * - * @param OrderAddress $v - * @return Order The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderAddressRelatedByAddressDelivery(OrderAddress $v = null) - { - if ($v === null) { - $this->setAddressDelivery(NULL); - } else { - $this->setAddressDelivery($v->getId()); - } - - $this->aOrderAddressRelatedByAddressDelivery = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the OrderAddress object, it will not be re-added. - if ($v !== null) { - $v->addOrderRelatedByAddressDelivery($this); - } - - - return $this; - } - - - /** - * Get the associated OrderAddress object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderAddress The associated OrderAddress object. - * @throws PropelException - */ - public function getOrderAddressRelatedByAddressDelivery(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrderAddressRelatedByAddressDelivery === null && ($this->address_delivery !== null) && $doQuery) { - $this->aOrderAddressRelatedByAddressDelivery = OrderAddressQuery::create()->findPk($this->address_delivery, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderAddressRelatedByAddressDelivery->addOrdersRelatedByAddressDelivery($this); - */ - } - - return $this->aOrderAddressRelatedByAddressDelivery; - } - - /** - * Declares an association between this object and a OrderStatus object. - * - * @param OrderStatus $v - * @return Order The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderStatus(OrderStatus $v = null) - { - if ($v === null) { - $this->setStatusId(NULL); - } else { - $this->setStatusId($v->getId()); - } - - $this->aOrderStatus = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the OrderStatus object, it will not be re-added. - if ($v !== null) { - $v->addOrder($this); - } - - - return $this; - } - - - /** - * Get the associated OrderStatus object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderStatus The associated OrderStatus object. - * @throws PropelException - */ - public function getOrderStatus(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrderStatus === null && ($this->status_id !== null) && $doQuery) { - $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->status_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderStatus->addOrders($this); - */ - } - - return $this->aOrderStatus; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('OrderProduct' == $relationName) { - $this->initOrderProducts(); - } - if ('CouponOrder' == $relationName) { - $this->initCouponOrders(); - } - } - - /** - * Clears out the collOrderProducts collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Order The current object (for fluent API support) - * @see addOrderProducts() - */ - public function clearOrderProducts() - { - $this->collOrderProducts = null; // important to set this to null since that means it is uninitialized - $this->collOrderProductsPartial = null; - - return $this; - } - - /** - * reset is the collOrderProducts collection loaded partially - * - * @return void - */ - public function resetPartialOrderProducts($v = true) - { - $this->collOrderProductsPartial = $v; - } - - /** - * Initializes the collOrderProducts collection. - * - * By default this just sets the collOrderProducts collection to an empty array (like clearcollOrderProducts()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrderProducts($overrideExisting = true) - { - if (null !== $this->collOrderProducts && !$overrideExisting) { - return; - } - $this->collOrderProducts = new PropelObjectCollection(); - $this->collOrderProducts->setModel('OrderProduct'); - } - - /** - * Gets an array of OrderProduct objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Order is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|OrderProduct[] List of OrderProduct objects - * @throws PropelException - */ - public function getOrderProducts($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrderProductsPartial && !$this->isNew(); - if (null === $this->collOrderProducts || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderProducts) { - // return empty collection - $this->initOrderProducts(); - } else { - $collOrderProducts = OrderProductQuery::create(null, $criteria) - ->filterByOrder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrderProductsPartial && count($collOrderProducts)) { - $this->initOrderProducts(false); - - foreach($collOrderProducts as $obj) { - if (false == $this->collOrderProducts->contains($obj)) { - $this->collOrderProducts->append($obj); - } - } - - $this->collOrderProductsPartial = true; - } - - $collOrderProducts->getInternalIterator()->rewind(); - return $collOrderProducts; - } - - if($partial && $this->collOrderProducts) { - foreach($this->collOrderProducts as $obj) { - if($obj->isNew()) { - $collOrderProducts[] = $obj; - } - } - } - - $this->collOrderProducts = $collOrderProducts; - $this->collOrderProductsPartial = false; - } - } - - return $this->collOrderProducts; - } - - /** - * Sets a collection of OrderProduct objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $orderProducts A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Order The current object (for fluent API support) - */ - public function setOrderProducts(PropelCollection $orderProducts, PropelPDO $con = null) - { - $orderProductsToDelete = $this->getOrderProducts(new Criteria(), $con)->diff($orderProducts); - - $this->orderProductsScheduledForDeletion = unserialize(serialize($orderProductsToDelete)); - - foreach ($orderProductsToDelete as $orderProductRemoved) { - $orderProductRemoved->setOrder(null); - } - - $this->collOrderProducts = null; - foreach ($orderProducts as $orderProduct) { - $this->addOrderProduct($orderProduct); - } - - $this->collOrderProducts = $orderProducts; - $this->collOrderProductsPartial = false; - - return $this; - } - - /** - * Returns the number of related OrderProduct objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related OrderProduct objects. - * @throws PropelException - */ - public function countOrderProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrderProductsPartial && !$this->isNew(); - if (null === $this->collOrderProducts || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderProducts) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrderProducts()); - } - $query = OrderProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrder($this) - ->count($con); - } - - return count($this->collOrderProducts); - } - - /** - * Method called to associate a OrderProduct object to this object - * through the OrderProduct foreign key attribute. - * - * @param OrderProduct $l OrderProduct - * @return Order The current object (for fluent API support) - */ - public function addOrderProduct(OrderProduct $l) - { - if ($this->collOrderProducts === null) { - $this->initOrderProducts(); - $this->collOrderProductsPartial = true; - } - if (!in_array($l, $this->collOrderProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderProduct($l); - } - - return $this; - } - - /** - * @param OrderProduct $orderProduct The orderProduct object to add. - */ - protected function doAddOrderProduct($orderProduct) - { - $this->collOrderProducts[]= $orderProduct; - $orderProduct->setOrder($this); - } - - /** - * @param OrderProduct $orderProduct The orderProduct object to remove. - * @return Order The current object (for fluent API support) - */ - public function removeOrderProduct($orderProduct) - { - if ($this->getOrderProducts()->contains($orderProduct)) { - $this->collOrderProducts->remove($this->collOrderProducts->search($orderProduct)); - if (null === $this->orderProductsScheduledForDeletion) { - $this->orderProductsScheduledForDeletion = clone $this->collOrderProducts; - $this->orderProductsScheduledForDeletion->clear(); - } - $this->orderProductsScheduledForDeletion[]= clone $orderProduct; - $orderProduct->setOrder(null); - } - - return $this; - } - - /** - * Clears out the collCouponOrders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Order The current object (for fluent API support) - * @see addCouponOrders() - */ - public function clearCouponOrders() - { - $this->collCouponOrders = null; // important to set this to null since that means it is uninitialized - $this->collCouponOrdersPartial = null; - - return $this; - } - - /** - * reset is the collCouponOrders collection loaded partially - * - * @return void - */ - public function resetPartialCouponOrders($v = true) - { - $this->collCouponOrdersPartial = $v; - } - - /** - * Initializes the collCouponOrders collection. - * - * By default this just sets the collCouponOrders collection to an empty array (like clearcollCouponOrders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initCouponOrders($overrideExisting = true) - { - if (null !== $this->collCouponOrders && !$overrideExisting) { - return; - } - $this->collCouponOrders = new PropelObjectCollection(); - $this->collCouponOrders->setModel('CouponOrder'); - } - - /** - * Gets an array of CouponOrder objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Order is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|CouponOrder[] List of CouponOrder objects - * @throws PropelException - */ - public function getCouponOrders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collCouponOrdersPartial && !$this->isNew(); - if (null === $this->collCouponOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponOrders) { - // return empty collection - $this->initCouponOrders(); - } else { - $collCouponOrders = CouponOrderQuery::create(null, $criteria) - ->filterByOrder($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collCouponOrdersPartial && count($collCouponOrders)) { - $this->initCouponOrders(false); - - foreach($collCouponOrders as $obj) { - if (false == $this->collCouponOrders->contains($obj)) { - $this->collCouponOrders->append($obj); - } - } - - $this->collCouponOrdersPartial = true; - } - - $collCouponOrders->getInternalIterator()->rewind(); - return $collCouponOrders; - } - - if($partial && $this->collCouponOrders) { - foreach($this->collCouponOrders as $obj) { - if($obj->isNew()) { - $collCouponOrders[] = $obj; - } - } - } - - $this->collCouponOrders = $collCouponOrders; - $this->collCouponOrdersPartial = false; - } - } - - return $this->collCouponOrders; - } - - /** - * Sets a collection of CouponOrder objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $couponOrders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Order The current object (for fluent API support) - */ - public function setCouponOrders(PropelCollection $couponOrders, PropelPDO $con = null) - { - $couponOrdersToDelete = $this->getCouponOrders(new Criteria(), $con)->diff($couponOrders); - - $this->couponOrdersScheduledForDeletion = unserialize(serialize($couponOrdersToDelete)); - - foreach ($couponOrdersToDelete as $couponOrderRemoved) { - $couponOrderRemoved->setOrder(null); - } - - $this->collCouponOrders = null; - foreach ($couponOrders as $couponOrder) { - $this->addCouponOrder($couponOrder); - } - - $this->collCouponOrders = $couponOrders; - $this->collCouponOrdersPartial = false; - - return $this; - } - - /** - * Returns the number of related CouponOrder objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related CouponOrder objects. - * @throws PropelException - */ - public function countCouponOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collCouponOrdersPartial && !$this->isNew(); - if (null === $this->collCouponOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collCouponOrders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getCouponOrders()); - } - $query = CouponOrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrder($this) - ->count($con); - } - - return count($this->collCouponOrders); - } - - /** - * Method called to associate a CouponOrder object to this object - * through the CouponOrder foreign key attribute. - * - * @param CouponOrder $l CouponOrder - * @return Order The current object (for fluent API support) - */ - public function addCouponOrder(CouponOrder $l) - { - if ($this->collCouponOrders === null) { - $this->initCouponOrders(); - $this->collCouponOrdersPartial = true; - } - if (!in_array($l, $this->collCouponOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddCouponOrder($l); - } - - return $this; - } - - /** - * @param CouponOrder $couponOrder The couponOrder object to add. - */ - protected function doAddCouponOrder($couponOrder) - { - $this->collCouponOrders[]= $couponOrder; - $couponOrder->setOrder($this); - } - - /** - * @param CouponOrder $couponOrder The couponOrder object to remove. - * @return Order The current object (for fluent API support) - */ - public function removeCouponOrder($couponOrder) - { - if ($this->getCouponOrders()->contains($couponOrder)) { - $this->collCouponOrders->remove($this->collCouponOrders->search($couponOrder)); - if (null === $this->couponOrdersScheduledForDeletion) { - $this->couponOrdersScheduledForDeletion = clone $this->collCouponOrders; - $this->couponOrdersScheduledForDeletion->clear(); - } - $this->couponOrdersScheduledForDeletion[]= clone $couponOrder; - $couponOrder->setOrder(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->ref = null; - $this->customer_id = null; - $this->address_invoice = null; - $this->address_delivery = null; - $this->invoice_date = null; - $this->currency_id = null; - $this->currency_rate = null; - $this->transaction = null; - $this->delivery_num = null; - $this->invoice = null; - $this->postage = null; - $this->payment = null; - $this->carrier = null; - $this->status_id = null; - $this->lang = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collOrderProducts) { - foreach ($this->collOrderProducts as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCouponOrders) { - foreach ($this->collCouponOrders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aCurrency instanceof Persistent) { - $this->aCurrency->clearAllReferences($deep); - } - if ($this->aCustomer instanceof Persistent) { - $this->aCustomer->clearAllReferences($deep); - } - if ($this->aOrderAddressRelatedByAddressInvoice instanceof Persistent) { - $this->aOrderAddressRelatedByAddressInvoice->clearAllReferences($deep); - } - if ($this->aOrderAddressRelatedByAddressDelivery instanceof Persistent) { - $this->aOrderAddressRelatedByAddressDelivery->clearAllReferences($deep); - } - if ($this->aOrderStatus instanceof Persistent) { - $this->aOrderStatus->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collOrderProducts instanceof PropelCollection) { - $this->collOrderProducts->clearIterator(); - } - $this->collOrderProducts = null; - if ($this->collCouponOrders instanceof PropelCollection) { - $this->collCouponOrders->clearIterator(); - } - $this->collCouponOrders = null; - $this->aCurrency = null; - $this->aCustomer = null; - $this->aOrderAddressRelatedByAddressInvoice = null; - $this->aOrderAddressRelatedByAddressDelivery = null; - $this->aOrderStatus = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Order The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderAddress.php b/core/lib/Thelia/Model/om/BaseOrderAddress.php deleted file mode 100755 index ac3339370..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderAddress.php +++ /dev/null @@ -1,2322 +0,0 @@ -id; - } - - /** - * Get the [customer_title_id] column value. - * - * @return int - */ - public function getCustomerTitleId() - { - return $this->customer_title_id; - } - - /** - * Get the [company] column value. - * - * @return string - */ - public function getCompany() - { - return $this->company; - } - - /** - * Get the [firstname] column value. - * - * @return string - */ - public function getFirstname() - { - return $this->firstname; - } - - /** - * Get the [lastname] column value. - * - * @return string - */ - public function getLastname() - { - return $this->lastname; - } - - /** - * Get the [address1] column value. - * - * @return string - */ - public function getAddress1() - { - return $this->address1; - } - - /** - * Get the [address2] column value. - * - * @return string - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * Get the [address3] column value. - * - * @return string - */ - public function getAddress3() - { - return $this->address3; - } - - /** - * Get the [zipcode] column value. - * - * @return string - */ - public function getZipcode() - { - return $this->zipcode; - } - - /** - * Get the [city] column value. - * - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * Get the [phone] column value. - * - * @return string - */ - public function getPhone() - { - return $this->phone; - } - - /** - * Get the [country_id] column value. - * - * @return int - */ - public function getCountryId() - { - return $this->country_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderAddressPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [customer_title_id] column. - * - * @param int $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setCustomerTitleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->customer_title_id !== $v) { - $this->customer_title_id = $v; - $this->modifiedColumns[] = OrderAddressPeer::CUSTOMER_TITLE_ID; - } - - - return $this; - } // setCustomerTitleId() - - /** - * Set the value of [company] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setCompany($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->company !== $v) { - $this->company = $v; - $this->modifiedColumns[] = OrderAddressPeer::COMPANY; - } - - - return $this; - } // setCompany() - - /** - * Set the value of [firstname] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setFirstname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->firstname !== $v) { - $this->firstname = $v; - $this->modifiedColumns[] = OrderAddressPeer::FIRSTNAME; - } - - - return $this; - } // setFirstname() - - /** - * Set the value of [lastname] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setLastname($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->lastname !== $v) { - $this->lastname = $v; - $this->modifiedColumns[] = OrderAddressPeer::LASTNAME; - } - - - return $this; - } // setLastname() - - /** - * Set the value of [address1] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setAddress1($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address1 !== $v) { - $this->address1 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS1; - } - - - return $this; - } // setAddress1() - - /** - * Set the value of [address2] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setAddress2($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address2 !== $v) { - $this->address2 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS2; - } - - - return $this; - } // setAddress2() - - /** - * Set the value of [address3] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setAddress3($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->address3 !== $v) { - $this->address3 = $v; - $this->modifiedColumns[] = OrderAddressPeer::ADDRESS3; - } - - - return $this; - } // setAddress3() - - /** - * Set the value of [zipcode] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setZipcode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->zipcode !== $v) { - $this->zipcode = $v; - $this->modifiedColumns[] = OrderAddressPeer::ZIPCODE; - } - - - return $this; - } // setZipcode() - - /** - * Set the value of [city] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setCity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->city !== $v) { - $this->city = $v; - $this->modifiedColumns[] = OrderAddressPeer::CITY; - } - - - return $this; - } // setCity() - - /** - * Set the value of [phone] column. - * - * @param string $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setPhone($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->phone !== $v) { - $this->phone = $v; - $this->modifiedColumns[] = OrderAddressPeer::PHONE; - } - - - return $this; - } // setPhone() - - /** - * Set the value of [country_id] column. - * - * @param int $v new value - * @return OrderAddress The current object (for fluent API support) - */ - public function setCountryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->country_id !== $v) { - $this->country_id = $v; - $this->modifiedColumns[] = OrderAddressPeer::COUNTRY_ID; - } - - - return $this; - } // setCountryId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderAddress The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = OrderAddressPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderAddress The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = OrderAddressPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->customer_title_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->company = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->firstname = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->lastname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->address1 = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->address2 = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->address3 = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->zipcode = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; - $this->city = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null; - $this->phone = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->country_id = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; - $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 14; // 14 = OrderAddressPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating OrderAddress object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = OrderAddressPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collOrdersRelatedByAddressInvoice = null; - - $this->collOrdersRelatedByAddressDelivery = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderAddressQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderAddressPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderAddressPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->ordersRelatedByAddressInvoiceScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressInvoiceScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressInvoiceScheduledForDeletion as $orderRelatedByAddressInvoice) { - // need to save related object because we set the relation to null - $orderRelatedByAddressInvoice->save($con); - } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = null; - } - } - - if ($this->collOrdersRelatedByAddressInvoice !== null) { - foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->ordersRelatedByAddressDeliveryScheduledForDeletion !== null) { - if (!$this->ordersRelatedByAddressDeliveryScheduledForDeletion->isEmpty()) { - foreach ($this->ordersRelatedByAddressDeliveryScheduledForDeletion as $orderRelatedByAddressDelivery) { - // need to save related object because we set the relation to null - $orderRelatedByAddressDelivery->save($con); - } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = null; - } - } - - if ($this->collOrdersRelatedByAddressDelivery !== null) { - foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderAddressPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderAddressPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderAddressPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) { - $modifiedColumns[':p' . $index++] = '`customer_title_id`'; - } - if ($this->isColumnModified(OrderAddressPeer::COMPANY)) { - $modifiedColumns[':p' . $index++] = '`company`'; - } - if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) { - $modifiedColumns[':p' . $index++] = '`firstname`'; - } - if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) { - $modifiedColumns[':p' . $index++] = '`lastname`'; - } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) { - $modifiedColumns[':p' . $index++] = '`address1`'; - } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) { - $modifiedColumns[':p' . $index++] = '`address2`'; - } - if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) { - $modifiedColumns[':p' . $index++] = '`address3`'; - } - if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) { - $modifiedColumns[':p' . $index++] = '`zipcode`'; - } - if ($this->isColumnModified(OrderAddressPeer::CITY)) { - $modifiedColumns[':p' . $index++] = '`city`'; - } - if ($this->isColumnModified(OrderAddressPeer::PHONE)) { - $modifiedColumns[':p' . $index++] = '`phone`'; - } - if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; - } - if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `order_address` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`customer_title_id`': - $stmt->bindValue($identifier, $this->customer_title_id, PDO::PARAM_INT); - break; - case '`company`': - $stmt->bindValue($identifier, $this->company, PDO::PARAM_STR); - break; - case '`firstname`': - $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); - break; - case '`lastname`': - $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); - break; - case '`address1`': - $stmt->bindValue($identifier, $this->address1, PDO::PARAM_STR); - break; - case '`address2`': - $stmt->bindValue($identifier, $this->address2, PDO::PARAM_STR); - break; - case '`address3`': - $stmt->bindValue($identifier, $this->address3, PDO::PARAM_STR); - break; - case '`zipcode`': - $stmt->bindValue($identifier, $this->zipcode, PDO::PARAM_STR); - break; - case '`city`': - $stmt->bindValue($identifier, $this->city, PDO::PARAM_STR); - break; - case '`phone`': - $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); - break; - case '`country_id`': - $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = OrderAddressPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collOrdersRelatedByAddressInvoice !== null) { - foreach ($this->collOrdersRelatedByAddressInvoice as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collOrdersRelatedByAddressDelivery !== null) { - foreach ($this->collOrdersRelatedByAddressDelivery as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCustomerTitleId(); - break; - case 2: - return $this->getCompany(); - break; - case 3: - return $this->getFirstname(); - break; - case 4: - return $this->getLastname(); - break; - case 5: - return $this->getAddress1(); - break; - case 6: - return $this->getAddress2(); - break; - case 7: - return $this->getAddress3(); - break; - case 8: - return $this->getZipcode(); - break; - case 9: - return $this->getCity(); - break; - case 10: - return $this->getPhone(); - break; - case 11: - return $this->getCountryId(); - break; - case 12: - return $this->getCreatedAt(); - break; - case 13: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderAddress'][$this->getPrimaryKey()] = true; - $keys = OrderAddressPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCustomerTitleId(), - $keys[2] => $this->getCompany(), - $keys[3] => $this->getFirstname(), - $keys[4] => $this->getLastname(), - $keys[5] => $this->getAddress1(), - $keys[6] => $this->getAddress2(), - $keys[7] => $this->getAddress3(), - $keys[8] => $this->getZipcode(), - $keys[9] => $this->getCity(), - $keys[10] => $this->getPhone(), - $keys[11] => $this->getCountryId(), - $keys[12] => $this->getCreatedAt(), - $keys[13] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collOrdersRelatedByAddressInvoice) { - $result['OrdersRelatedByAddressInvoice'] = $this->collOrdersRelatedByAddressInvoice->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collOrdersRelatedByAddressDelivery) { - $result['OrdersRelatedByAddressDelivery'] = $this->collOrdersRelatedByAddressDelivery->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderAddressPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCustomerTitleId($value); - break; - case 2: - $this->setCompany($value); - break; - case 3: - $this->setFirstname($value); - break; - case 4: - $this->setLastname($value); - break; - case 5: - $this->setAddress1($value); - break; - case 6: - $this->setAddress2($value); - break; - case 7: - $this->setAddress3($value); - break; - case 8: - $this->setZipcode($value); - break; - case 9: - $this->setCity($value); - break; - case 10: - $this->setPhone($value); - break; - case 11: - $this->setCountryId($value); - break; - case 12: - $this->setCreatedAt($value); - break; - case 13: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = OrderAddressPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCustomerTitleId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCompany($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFirstname($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setLastname($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAddress1($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setAddress2($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setAddress3($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setZipcode($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setCity($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setPhone($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setCountryId($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderAddressPeer::ID)) $criteria->add(OrderAddressPeer::ID, $this->id); - if ($this->isColumnModified(OrderAddressPeer::CUSTOMER_TITLE_ID)) $criteria->add(OrderAddressPeer::CUSTOMER_TITLE_ID, $this->customer_title_id); - if ($this->isColumnModified(OrderAddressPeer::COMPANY)) $criteria->add(OrderAddressPeer::COMPANY, $this->company); - if ($this->isColumnModified(OrderAddressPeer::FIRSTNAME)) $criteria->add(OrderAddressPeer::FIRSTNAME, $this->firstname); - if ($this->isColumnModified(OrderAddressPeer::LASTNAME)) $criteria->add(OrderAddressPeer::LASTNAME, $this->lastname); - if ($this->isColumnModified(OrderAddressPeer::ADDRESS1)) $criteria->add(OrderAddressPeer::ADDRESS1, $this->address1); - if ($this->isColumnModified(OrderAddressPeer::ADDRESS2)) $criteria->add(OrderAddressPeer::ADDRESS2, $this->address2); - if ($this->isColumnModified(OrderAddressPeer::ADDRESS3)) $criteria->add(OrderAddressPeer::ADDRESS3, $this->address3); - if ($this->isColumnModified(OrderAddressPeer::ZIPCODE)) $criteria->add(OrderAddressPeer::ZIPCODE, $this->zipcode); - if ($this->isColumnModified(OrderAddressPeer::CITY)) $criteria->add(OrderAddressPeer::CITY, $this->city); - if ($this->isColumnModified(OrderAddressPeer::PHONE)) $criteria->add(OrderAddressPeer::PHONE, $this->phone); - if ($this->isColumnModified(OrderAddressPeer::COUNTRY_ID)) $criteria->add(OrderAddressPeer::COUNTRY_ID, $this->country_id); - if ($this->isColumnModified(OrderAddressPeer::CREATED_AT)) $criteria->add(OrderAddressPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderAddressPeer::UPDATED_AT)) $criteria->add(OrderAddressPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - $criteria->add(OrderAddressPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of OrderAddress (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCustomerTitleId($this->getCustomerTitleId()); - $copyObj->setCompany($this->getCompany()); - $copyObj->setFirstname($this->getFirstname()); - $copyObj->setLastname($this->getLastname()); - $copyObj->setAddress1($this->getAddress1()); - $copyObj->setAddress2($this->getAddress2()); - $copyObj->setAddress3($this->getAddress3()); - $copyObj->setZipcode($this->getZipcode()); - $copyObj->setCity($this->getCity()); - $copyObj->setPhone($this->getPhone()); - $copyObj->setCountryId($this->getCountryId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getOrdersRelatedByAddressInvoice() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressInvoice($relObj->copy($deepCopy)); - } - } - - foreach ($this->getOrdersRelatedByAddressDelivery() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderRelatedByAddressDelivery($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return OrderAddress Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return OrderAddressPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderAddressPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('OrderRelatedByAddressInvoice' == $relationName) { - $this->initOrdersRelatedByAddressInvoice(); - } - if ('OrderRelatedByAddressDelivery' == $relationName) { - $this->initOrdersRelatedByAddressDelivery(); - } - } - - /** - * Clears out the collOrdersRelatedByAddressInvoice collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return OrderAddress The current object (for fluent API support) - * @see addOrdersRelatedByAddressInvoice() - */ - public function clearOrdersRelatedByAddressInvoice() - { - $this->collOrdersRelatedByAddressInvoice = null; // important to set this to null since that means it is uninitialized - $this->collOrdersRelatedByAddressInvoicePartial = null; - - return $this; - } - - /** - * reset is the collOrdersRelatedByAddressInvoice collection loaded partially - * - * @return void - */ - public function resetPartialOrdersRelatedByAddressInvoice($v = true) - { - $this->collOrdersRelatedByAddressInvoicePartial = $v; - } - - /** - * Initializes the collOrdersRelatedByAddressInvoice collection. - * - * By default this just sets the collOrdersRelatedByAddressInvoice collection to an empty array (like clearcollOrdersRelatedByAddressInvoice()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrdersRelatedByAddressInvoice($overrideExisting = true) - { - if (null !== $this->collOrdersRelatedByAddressInvoice && !$overrideExisting) { - return; - } - $this->collOrdersRelatedByAddressInvoice = new PropelObjectCollection(); - $this->collOrdersRelatedByAddressInvoice->setModel('Order'); - } - - /** - * Gets an array of Order objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this OrderAddress is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Order[] List of Order objects - * @throws PropelException - */ - public function getOrdersRelatedByAddressInvoice($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { - // return empty collection - $this->initOrdersRelatedByAddressInvoice(); - } else { - $collOrdersRelatedByAddressInvoice = OrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressInvoice($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressInvoicePartial && count($collOrdersRelatedByAddressInvoice)) { - $this->initOrdersRelatedByAddressInvoice(false); - - foreach($collOrdersRelatedByAddressInvoice as $obj) { - if (false == $this->collOrdersRelatedByAddressInvoice->contains($obj)) { - $this->collOrdersRelatedByAddressInvoice->append($obj); - } - } - - $this->collOrdersRelatedByAddressInvoicePartial = true; - } - - $collOrdersRelatedByAddressInvoice->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressInvoice; - } - - if($partial && $this->collOrdersRelatedByAddressInvoice) { - foreach($this->collOrdersRelatedByAddressInvoice as $obj) { - if($obj->isNew()) { - $collOrdersRelatedByAddressInvoice[] = $obj; - } - } - } - - $this->collOrdersRelatedByAddressInvoice = $collOrdersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; - } - } - - return $this->collOrdersRelatedByAddressInvoice; - } - - /** - * Sets a collection of OrderRelatedByAddressInvoice objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $ordersRelatedByAddressInvoice A Propel collection. - * @param PropelPDO $con Optional connection object - * @return OrderAddress The current object (for fluent API support) - */ - public function setOrdersRelatedByAddressInvoice(PropelCollection $ordersRelatedByAddressInvoice, PropelPDO $con = null) - { - $ordersRelatedByAddressInvoiceToDelete = $this->getOrdersRelatedByAddressInvoice(new Criteria(), $con)->diff($ordersRelatedByAddressInvoice); - - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressInvoiceToDelete)); - - foreach ($ordersRelatedByAddressInvoiceToDelete as $orderRelatedByAddressInvoiceRemoved) { - $orderRelatedByAddressInvoiceRemoved->setOrderAddressRelatedByAddressInvoice(null); - } - - $this->collOrdersRelatedByAddressInvoice = null; - foreach ($ordersRelatedByAddressInvoice as $orderRelatedByAddressInvoice) { - $this->addOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice); - } - - $this->collOrdersRelatedByAddressInvoice = $ordersRelatedByAddressInvoice; - $this->collOrdersRelatedByAddressInvoicePartial = false; - - return $this; - } - - /** - * Returns the number of related Order objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Order objects. - * @throws PropelException - */ - public function countOrdersRelatedByAddressInvoice(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrdersRelatedByAddressInvoicePartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressInvoice || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressInvoice) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressInvoice()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderAddressRelatedByAddressInvoice($this) - ->count($con); - } - - return count($this->collOrdersRelatedByAddressInvoice); - } - - /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. - * - * @param Order $l Order - * @return OrderAddress The current object (for fluent API support) - */ - public function addOrderRelatedByAddressInvoice(Order $l) - { - if ($this->collOrdersRelatedByAddressInvoice === null) { - $this->initOrdersRelatedByAddressInvoice(); - $this->collOrdersRelatedByAddressInvoicePartial = true; - } - if (!in_array($l, $this->collOrdersRelatedByAddressInvoice->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressInvoice($l); - } - - return $this; - } - - /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to add. - */ - protected function doAddOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) - { - $this->collOrdersRelatedByAddressInvoice[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice($this); - } - - /** - * @param OrderRelatedByAddressInvoice $orderRelatedByAddressInvoice The orderRelatedByAddressInvoice object to remove. - * @return OrderAddress The current object (for fluent API support) - */ - public function removeOrderRelatedByAddressInvoice($orderRelatedByAddressInvoice) - { - if ($this->getOrdersRelatedByAddressInvoice()->contains($orderRelatedByAddressInvoice)) { - $this->collOrdersRelatedByAddressInvoice->remove($this->collOrdersRelatedByAddressInvoice->search($orderRelatedByAddressInvoice)); - if (null === $this->ordersRelatedByAddressInvoiceScheduledForDeletion) { - $this->ordersRelatedByAddressInvoiceScheduledForDeletion = clone $this->collOrdersRelatedByAddressInvoice; - $this->ordersRelatedByAddressInvoiceScheduledForDeletion->clear(); - } - $this->ordersRelatedByAddressInvoiceScheduledForDeletion[]= $orderRelatedByAddressInvoice; - $orderRelatedByAddressInvoice->setOrderAddressRelatedByAddressInvoice(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressInvoiceJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); - - return $this->getOrdersRelatedByAddressInvoice($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressInvoiceJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); - - return $this->getOrdersRelatedByAddressInvoice($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressInvoice from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressInvoiceJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); - - return $this->getOrdersRelatedByAddressInvoice($query, $con); - } - - /** - * Clears out the collOrdersRelatedByAddressDelivery collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return OrderAddress The current object (for fluent API support) - * @see addOrdersRelatedByAddressDelivery() - */ - public function clearOrdersRelatedByAddressDelivery() - { - $this->collOrdersRelatedByAddressDelivery = null; // important to set this to null since that means it is uninitialized - $this->collOrdersRelatedByAddressDeliveryPartial = null; - - return $this; - } - - /** - * reset is the collOrdersRelatedByAddressDelivery collection loaded partially - * - * @return void - */ - public function resetPartialOrdersRelatedByAddressDelivery($v = true) - { - $this->collOrdersRelatedByAddressDeliveryPartial = $v; - } - - /** - * Initializes the collOrdersRelatedByAddressDelivery collection. - * - * By default this just sets the collOrdersRelatedByAddressDelivery collection to an empty array (like clearcollOrdersRelatedByAddressDelivery()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrdersRelatedByAddressDelivery($overrideExisting = true) - { - if (null !== $this->collOrdersRelatedByAddressDelivery && !$overrideExisting) { - return; - } - $this->collOrdersRelatedByAddressDelivery = new PropelObjectCollection(); - $this->collOrdersRelatedByAddressDelivery->setModel('Order'); - } - - /** - * Gets an array of Order objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this OrderAddress is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Order[] List of Order objects - * @throws PropelException - */ - public function getOrdersRelatedByAddressDelivery($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { - // return empty collection - $this->initOrdersRelatedByAddressDelivery(); - } else { - $collOrdersRelatedByAddressDelivery = OrderQuery::create(null, $criteria) - ->filterByOrderAddressRelatedByAddressDelivery($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrdersRelatedByAddressDeliveryPartial && count($collOrdersRelatedByAddressDelivery)) { - $this->initOrdersRelatedByAddressDelivery(false); - - foreach($collOrdersRelatedByAddressDelivery as $obj) { - if (false == $this->collOrdersRelatedByAddressDelivery->contains($obj)) { - $this->collOrdersRelatedByAddressDelivery->append($obj); - } - } - - $this->collOrdersRelatedByAddressDeliveryPartial = true; - } - - $collOrdersRelatedByAddressDelivery->getInternalIterator()->rewind(); - return $collOrdersRelatedByAddressDelivery; - } - - if($partial && $this->collOrdersRelatedByAddressDelivery) { - foreach($this->collOrdersRelatedByAddressDelivery as $obj) { - if($obj->isNew()) { - $collOrdersRelatedByAddressDelivery[] = $obj; - } - } - } - - $this->collOrdersRelatedByAddressDelivery = $collOrdersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; - } - } - - return $this->collOrdersRelatedByAddressDelivery; - } - - /** - * Sets a collection of OrderRelatedByAddressDelivery objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $ordersRelatedByAddressDelivery A Propel collection. - * @param PropelPDO $con Optional connection object - * @return OrderAddress The current object (for fluent API support) - */ - public function setOrdersRelatedByAddressDelivery(PropelCollection $ordersRelatedByAddressDelivery, PropelPDO $con = null) - { - $ordersRelatedByAddressDeliveryToDelete = $this->getOrdersRelatedByAddressDelivery(new Criteria(), $con)->diff($ordersRelatedByAddressDelivery); - - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = unserialize(serialize($ordersRelatedByAddressDeliveryToDelete)); - - foreach ($ordersRelatedByAddressDeliveryToDelete as $orderRelatedByAddressDeliveryRemoved) { - $orderRelatedByAddressDeliveryRemoved->setOrderAddressRelatedByAddressDelivery(null); - } - - $this->collOrdersRelatedByAddressDelivery = null; - foreach ($ordersRelatedByAddressDelivery as $orderRelatedByAddressDelivery) { - $this->addOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery); - } - - $this->collOrdersRelatedByAddressDelivery = $ordersRelatedByAddressDelivery; - $this->collOrdersRelatedByAddressDeliveryPartial = false; - - return $this; - } - - /** - * Returns the number of related Order objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Order objects. - * @throws PropelException - */ - public function countOrdersRelatedByAddressDelivery(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrdersRelatedByAddressDeliveryPartial && !$this->isNew(); - if (null === $this->collOrdersRelatedByAddressDelivery || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrdersRelatedByAddressDelivery) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrdersRelatedByAddressDelivery()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderAddressRelatedByAddressDelivery($this) - ->count($con); - } - - return count($this->collOrdersRelatedByAddressDelivery); - } - - /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. - * - * @param Order $l Order - * @return OrderAddress The current object (for fluent API support) - */ - public function addOrderRelatedByAddressDelivery(Order $l) - { - if ($this->collOrdersRelatedByAddressDelivery === null) { - $this->initOrdersRelatedByAddressDelivery(); - $this->collOrdersRelatedByAddressDeliveryPartial = true; - } - if (!in_array($l, $this->collOrdersRelatedByAddressDelivery->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderRelatedByAddressDelivery($l); - } - - return $this; - } - - /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to add. - */ - protected function doAddOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) - { - $this->collOrdersRelatedByAddressDelivery[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery($this); - } - - /** - * @param OrderRelatedByAddressDelivery $orderRelatedByAddressDelivery The orderRelatedByAddressDelivery object to remove. - * @return OrderAddress The current object (for fluent API support) - */ - public function removeOrderRelatedByAddressDelivery($orderRelatedByAddressDelivery) - { - if ($this->getOrdersRelatedByAddressDelivery()->contains($orderRelatedByAddressDelivery)) { - $this->collOrdersRelatedByAddressDelivery->remove($this->collOrdersRelatedByAddressDelivery->search($orderRelatedByAddressDelivery)); - if (null === $this->ordersRelatedByAddressDeliveryScheduledForDeletion) { - $this->ordersRelatedByAddressDeliveryScheduledForDeletion = clone $this->collOrdersRelatedByAddressDelivery; - $this->ordersRelatedByAddressDeliveryScheduledForDeletion->clear(); - } - $this->ordersRelatedByAddressDeliveryScheduledForDeletion[]= $orderRelatedByAddressDelivery; - $orderRelatedByAddressDelivery->setOrderAddressRelatedByAddressDelivery(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressDeliveryJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); - - return $this->getOrdersRelatedByAddressDelivery($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressDeliveryJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); - - return $this->getOrdersRelatedByAddressDelivery($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderAddress is new, it will return - * an empty collection; or if this OrderAddress has previously - * been saved, it will retrieve related OrdersRelatedByAddressDelivery from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderAddress. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersRelatedByAddressDeliveryJoinOrderStatus($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderStatus', $join_behavior); - - return $this->getOrdersRelatedByAddressDelivery($query, $con); - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->customer_title_id = null; - $this->company = null; - $this->firstname = null; - $this->lastname = null; - $this->address1 = null; - $this->address2 = null; - $this->address3 = null; - $this->zipcode = null; - $this->city = null; - $this->phone = null; - $this->country_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collOrdersRelatedByAddressInvoice) { - foreach ($this->collOrdersRelatedByAddressInvoice as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collOrdersRelatedByAddressDelivery) { - foreach ($this->collOrdersRelatedByAddressDelivery as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collOrdersRelatedByAddressInvoice instanceof PropelCollection) { - $this->collOrdersRelatedByAddressInvoice->clearIterator(); - } - $this->collOrdersRelatedByAddressInvoice = null; - if ($this->collOrdersRelatedByAddressDelivery instanceof PropelCollection) { - $this->collOrdersRelatedByAddressDelivery->clearIterator(); - } - $this->collOrdersRelatedByAddressDelivery = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderAddressPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return OrderAddress The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderAddressPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php b/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php deleted file mode 100755 index ab7a67728..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderAddressPeer.php +++ /dev/null @@ -1,842 +0,0 @@ - array ('Id', 'CustomerTitleId', 'Company', 'Firstname', 'Lastname', 'Address1', 'Address2', 'Address3', 'Zipcode', 'City', 'Phone', 'CountryId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'customerTitleId', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'countryId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (OrderAddressPeer::ID, OrderAddressPeer::CUSTOMER_TITLE_ID, OrderAddressPeer::COMPANY, OrderAddressPeer::FIRSTNAME, OrderAddressPeer::LASTNAME, OrderAddressPeer::ADDRESS1, OrderAddressPeer::ADDRESS2, OrderAddressPeer::ADDRESS3, OrderAddressPeer::ZIPCODE, OrderAddressPeer::CITY, OrderAddressPeer::PHONE, OrderAddressPeer::COUNTRY_ID, OrderAddressPeer::CREATED_AT, OrderAddressPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CUSTOMER_TITLE_ID', 'COMPANY', 'FIRSTNAME', 'LASTNAME', 'ADDRESS1', 'ADDRESS2', 'ADDRESS3', 'ZIPCODE', 'CITY', 'PHONE', 'COUNTRY_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'customer_title_id', 'company', 'firstname', 'lastname', 'address1', 'address2', 'address3', 'zipcode', 'city', 'phone', 'country_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderAddressPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CustomerTitleId' => 1, 'Company' => 2, 'Firstname' => 3, 'Lastname' => 4, 'Address1' => 5, 'Address2' => 6, 'Address3' => 7, 'Zipcode' => 8, 'City' => 9, 'Phone' => 10, 'CountryId' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'customerTitleId' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'countryId' => 11, 'createdAt' => 12, 'updatedAt' => 13, ), - BasePeer::TYPE_COLNAME => array (OrderAddressPeer::ID => 0, OrderAddressPeer::CUSTOMER_TITLE_ID => 1, OrderAddressPeer::COMPANY => 2, OrderAddressPeer::FIRSTNAME => 3, OrderAddressPeer::LASTNAME => 4, OrderAddressPeer::ADDRESS1 => 5, OrderAddressPeer::ADDRESS2 => 6, OrderAddressPeer::ADDRESS3 => 7, OrderAddressPeer::ZIPCODE => 8, OrderAddressPeer::CITY => 9, OrderAddressPeer::PHONE => 10, OrderAddressPeer::COUNTRY_ID => 11, OrderAddressPeer::CREATED_AT => 12, OrderAddressPeer::UPDATED_AT => 13, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CUSTOMER_TITLE_ID' => 1, 'COMPANY' => 2, 'FIRSTNAME' => 3, 'LASTNAME' => 4, 'ADDRESS1' => 5, 'ADDRESS2' => 6, 'ADDRESS3' => 7, 'ZIPCODE' => 8, 'CITY' => 9, 'PHONE' => 10, 'COUNTRY_ID' => 11, 'CREATED_AT' => 12, 'UPDATED_AT' => 13, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'customer_title_id' => 1, 'company' => 2, 'firstname' => 3, 'lastname' => 4, 'address1' => 5, 'address2' => 6, 'address3' => 7, 'zipcode' => 8, 'city' => 9, 'phone' => 10, 'country_id' => 11, 'created_at' => 12, 'updated_at' => 13, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderAddressPeer::getFieldNames($toType); - $key = isset(OrderAddressPeer::$fieldKeys[$fromType][$name]) ? OrderAddressPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderAddressPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, OrderAddressPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return OrderAddressPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. OrderAddressPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderAddressPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderAddressPeer::ID); - $criteria->addSelectColumn(OrderAddressPeer::CUSTOMER_TITLE_ID); - $criteria->addSelectColumn(OrderAddressPeer::COMPANY); - $criteria->addSelectColumn(OrderAddressPeer::FIRSTNAME); - $criteria->addSelectColumn(OrderAddressPeer::LASTNAME); - $criteria->addSelectColumn(OrderAddressPeer::ADDRESS1); - $criteria->addSelectColumn(OrderAddressPeer::ADDRESS2); - $criteria->addSelectColumn(OrderAddressPeer::ADDRESS3); - $criteria->addSelectColumn(OrderAddressPeer::ZIPCODE); - $criteria->addSelectColumn(OrderAddressPeer::CITY); - $criteria->addSelectColumn(OrderAddressPeer::PHONE); - $criteria->addSelectColumn(OrderAddressPeer::COUNTRY_ID); - $criteria->addSelectColumn(OrderAddressPeer::CREATED_AT); - $criteria->addSelectColumn(OrderAddressPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.customer_title_id'); - $criteria->addSelectColumn($alias . '.company'); - $criteria->addSelectColumn($alias . '.firstname'); - $criteria->addSelectColumn($alias . '.lastname'); - $criteria->addSelectColumn($alias . '.address1'); - $criteria->addSelectColumn($alias . '.address2'); - $criteria->addSelectColumn($alias . '.address3'); - $criteria->addSelectColumn($alias . '.zipcode'); - $criteria->addSelectColumn($alias . '.city'); - $criteria->addSelectColumn($alias . '.phone'); - $criteria->addSelectColumn($alias . '.country_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderAddressPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return OrderAddress - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = OrderAddressPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return OrderAddressPeer::populateObjects(OrderAddressPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderAddressPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param OrderAddress $obj A OrderAddress object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - OrderAddressPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A OrderAddress object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof OrderAddress) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderAddress object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderAddressPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return OrderAddress Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(OrderAddressPeer::$instances[$key])) { - return OrderAddressPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderAddressPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderAddressPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order_address - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in OrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderPeer::clearInstancePool(); - // Invalidate objects in OrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderAddressPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderAddressPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderAddressPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderAddressPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (OrderAddress object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderAddressPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderAddressPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderAddressPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(OrderAddressPeer::DATABASE_NAME)->getTable(OrderAddressPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderAddressPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderAddressPeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderAddressTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderAddressPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a OrderAddress or Criteria object. - * - * @param mixed $values Criteria or OrderAddress object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from OrderAddress object - } - - if ($criteria->containsKey(OrderAddressPeer::ID) && $criteria->keyContainsValue(OrderAddressPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderAddressPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a OrderAddress or Criteria object. - * - * @param mixed $values Criteria or OrderAddress object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderAddressPeer::ID); - $value = $criteria->remove(OrderAddressPeer::ID); - if ($value) { - $selectCriteria->add(OrderAddressPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderAddressPeer::TABLE_NAME); - } - - } else { // $values is OrderAddress object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order_address table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(OrderAddressPeer::TABLE_NAME, $con, OrderAddressPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderAddressPeer::clearInstancePool(); - OrderAddressPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a OrderAddress or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderAddress object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - OrderAddressPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof OrderAddress) { // it's a model object - // invalidate the cache for this single object - OrderAddressPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - $criteria->add(OrderAddressPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - OrderAddressPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderAddressPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - OrderAddressPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given OrderAddress object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param OrderAddress $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(OrderAddressPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderAddressPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(OrderAddressPeer::DATABASE_NAME, OrderAddressPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return OrderAddress - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = OrderAddressPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - $criteria->add(OrderAddressPeer::ID, $pk); - - $v = OrderAddressPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return OrderAddress[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(OrderAddressPeer::DATABASE_NAME); - $criteria->add(OrderAddressPeer::ID, $pks, Criteria::IN); - $objs = OrderAddressPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseOrderAddressPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderAddressPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php b/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php deleted file mode 100755 index 71b8135e5..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderAddressQuery.php +++ /dev/null @@ -1,992 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderAddressPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(OrderAddressPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderAddress A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderAddress A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `customer_title_id`, `company`, `firstname`, `lastname`, `address1`, `address2`, `address3`, `zipcode`, `city`, `phone`, `country_id`, `created_at`, `updated_at` FROM `order_address` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderAddress(); - $obj->hydrate($row); - OrderAddressPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderAddress|OrderAddress[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|OrderAddress[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderAddressPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderAddressPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderAddressPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderAddressPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAddressPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the customer_title_id column - * - * Example usage: - * - * $query->filterByCustomerTitleId(1234); // WHERE customer_title_id = 1234 - * $query->filterByCustomerTitleId(array(12, 34)); // WHERE customer_title_id IN (12, 34) - * $query->filterByCustomerTitleId(array('min' => 12)); // WHERE customer_title_id >= 12 - * $query->filterByCustomerTitleId(array('max' => 12)); // WHERE customer_title_id <= 12 - * - * - * @param mixed $customerTitleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByCustomerTitleId($customerTitleId = null, $comparison = null) - { - if (is_array($customerTitleId)) { - $useMinMax = false; - if (isset($customerTitleId['min'])) { - $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerTitleId['max'])) { - $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAddressPeer::CUSTOMER_TITLE_ID, $customerTitleId, $comparison); - } - - /** - * Filter the query on the company column - * - * Example usage: - * - * $query->filterByCompany('fooValue'); // WHERE company = 'fooValue' - * $query->filterByCompany('%fooValue%'); // WHERE company LIKE '%fooValue%' - * - * - * @param string $company The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByCompany($company = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($company)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $company)) { - $company = str_replace('*', '%', $company); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::COMPANY, $company, $comparison); - } - - /** - * Filter the query on the firstname column - * - * Example usage: - * - * $query->filterByFirstname('fooValue'); // WHERE firstname = 'fooValue' - * $query->filterByFirstname('%fooValue%'); // WHERE firstname LIKE '%fooValue%' - * - * - * @param string $firstname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByFirstname($firstname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($firstname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $firstname)) { - $firstname = str_replace('*', '%', $firstname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::FIRSTNAME, $firstname, $comparison); - } - - /** - * Filter the query on the lastname column - * - * Example usage: - * - * $query->filterByLastname('fooValue'); // WHERE lastname = 'fooValue' - * $query->filterByLastname('%fooValue%'); // WHERE lastname LIKE '%fooValue%' - * - * - * @param string $lastname The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByLastname($lastname = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lastname)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lastname)) { - $lastname = str_replace('*', '%', $lastname); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::LASTNAME, $lastname, $comparison); - } - - /** - * Filter the query on the address1 column - * - * Example usage: - * - * $query->filterByAddress1('fooValue'); // WHERE address1 = 'fooValue' - * $query->filterByAddress1('%fooValue%'); // WHERE address1 LIKE '%fooValue%' - * - * - * @param string $address1 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByAddress1($address1 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address1)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address1)) { - $address1 = str_replace('*', '%', $address1); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::ADDRESS1, $address1, $comparison); - } - - /** - * Filter the query on the address2 column - * - * Example usage: - * - * $query->filterByAddress2('fooValue'); // WHERE address2 = 'fooValue' - * $query->filterByAddress2('%fooValue%'); // WHERE address2 LIKE '%fooValue%' - * - * - * @param string $address2 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByAddress2($address2 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address2)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address2)) { - $address2 = str_replace('*', '%', $address2); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::ADDRESS2, $address2, $comparison); - } - - /** - * Filter the query on the address3 column - * - * Example usage: - * - * $query->filterByAddress3('fooValue'); // WHERE address3 = 'fooValue' - * $query->filterByAddress3('%fooValue%'); // WHERE address3 LIKE '%fooValue%' - * - * - * @param string $address3 The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByAddress3($address3 = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($address3)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $address3)) { - $address3 = str_replace('*', '%', $address3); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::ADDRESS3, $address3, $comparison); - } - - /** - * Filter the query on the zipcode column - * - * Example usage: - * - * $query->filterByZipcode('fooValue'); // WHERE zipcode = 'fooValue' - * $query->filterByZipcode('%fooValue%'); // WHERE zipcode LIKE '%fooValue%' - * - * - * @param string $zipcode The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByZipcode($zipcode = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($zipcode)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $zipcode)) { - $zipcode = str_replace('*', '%', $zipcode); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::ZIPCODE, $zipcode, $comparison); - } - - /** - * Filter the query on the city column - * - * Example usage: - * - * $query->filterByCity('fooValue'); // WHERE city = 'fooValue' - * $query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%' - * - * - * @param string $city The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByCity($city = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($city)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $city)) { - $city = str_replace('*', '%', $city); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::CITY, $city, $comparison); - } - - /** - * Filter the query on the phone column - * - * Example usage: - * - * $query->filterByPhone('fooValue'); // WHERE phone = 'fooValue' - * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%' - * - * - * @param string $phone The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByPhone($phone = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($phone)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $phone)) { - $phone = str_replace('*', '%', $phone); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderAddressPeer::PHONE, $phone, $comparison); - } - - /** - * Filter the query on the country_id column - * - * Example usage: - * - * $query->filterByCountryId(1234); // WHERE country_id = 1234 - * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 - * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 - * - * - * @param mixed $countryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByCountryId($countryId = null, $comparison = null) - { - if (is_array($countryId)) { - $useMinMax = false; - if (isset($countryId['min'])) { - $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($countryId['max'])) { - $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAddressPeer::COUNTRY_ID, $countryId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAddressPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderRelatedByAddressInvoice($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressInvoice(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - return $this - ->useOrderRelatedByAddressInvoiceQuery() - ->filterByPrimaryKeys($order->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderRelatedByAddressInvoice() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressInvoice relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function joinOrderRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressInvoice'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderRelatedByAddressInvoice'); - } - - return $this; - } - - /** - * Use the OrderRelatedByAddressInvoice relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrderRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressInvoice', '\Thelia\Model\OrderQuery'); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderAddressQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderRelatedByAddressDelivery($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(OrderAddressPeer::ID, $order->getAddressDelivery(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - return $this - ->useOrderRelatedByAddressDeliveryQuery() - ->filterByPrimaryKeys($order->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderRelatedByAddressDelivery() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderRelatedByAddressDelivery relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function joinOrderRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderRelatedByAddressDelivery'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderRelatedByAddressDelivery'); - } - - return $this; - } - - /** - * Use the OrderRelatedByAddressDelivery relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrderRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderRelatedByAddressDelivery', '\Thelia\Model\OrderQuery'); - } - - /** - * Exclude object from result - * - * @param OrderAddress $orderAddress Object to remove from the list of results - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function prune($orderAddress = null) - { - if ($orderAddress) { - $this->addUsingAlias(OrderAddressPeer::ID, $orderAddress->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderAddressPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderAddressPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderAddressPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderAddressPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderAddressPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return OrderAddressQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderAddressPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseOrderFeature.php b/core/lib/Thelia/Model/om/BaseOrderFeature.php deleted file mode 100755 index 20a5e584f..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderFeature.php +++ /dev/null @@ -1,1255 +0,0 @@ -id; - } - - /** - * Get the [order_product_id] column value. - * - * @return int - */ - public function getOrderProductId() - { - return $this->order_product_id; - } - - /** - * Get the [feature_desc] column value. - * - * @return string - */ - public function getFeatureDesc() - { - return $this->feature_desc; - } - - /** - * Get the [feature_av_desc] column value. - * - * @return string - */ - public function getFeatureAvDesc() - { - return $this->feature_av_desc; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return OrderFeature The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderFeaturePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [order_product_id] column. - * - * @param int $v new value - * @return OrderFeature The current object (for fluent API support) - */ - public function setOrderProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->order_product_id !== $v) { - $this->order_product_id = $v; - $this->modifiedColumns[] = OrderFeaturePeer::ORDER_PRODUCT_ID; - } - - if ($this->aOrderProduct !== null && $this->aOrderProduct->getId() !== $v) { - $this->aOrderProduct = null; - } - - - return $this; - } // setOrderProductId() - - /** - * Set the value of [feature_desc] column. - * - * @param string $v new value - * @return OrderFeature The current object (for fluent API support) - */ - public function setFeatureDesc($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->feature_desc !== $v) { - $this->feature_desc = $v; - $this->modifiedColumns[] = OrderFeaturePeer::FEATURE_DESC; - } - - - return $this; - } // setFeatureDesc() - - /** - * Set the value of [feature_av_desc] column. - * - * @param string $v new value - * @return OrderFeature The current object (for fluent API support) - */ - public function setFeatureAvDesc($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->feature_av_desc !== $v) { - $this->feature_av_desc = $v; - $this->modifiedColumns[] = OrderFeaturePeer::FEATURE_AV_DESC; - } - - - return $this; - } // setFeatureAvDesc() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderFeature The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = OrderFeaturePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderFeature The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = OrderFeaturePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->order_product_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->feature_desc = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->feature_av_desc = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = OrderFeaturePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating OrderFeature object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aOrderProduct !== null && $this->order_product_id !== $this->aOrderProduct->getId()) { - $this->aOrderProduct = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = OrderFeaturePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aOrderProduct = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderFeatureQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderFeaturePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderFeaturePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrderProduct !== null) { - if ($this->aOrderProduct->isModified() || $this->aOrderProduct->isNew()) { - $affectedRows += $this->aOrderProduct->save($con); - } - $this->setOrderProduct($this->aOrderProduct); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderFeaturePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderFeaturePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderFeaturePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderFeaturePeer::ORDER_PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`order_product_id`'; - } - if ($this->isColumnModified(OrderFeaturePeer::FEATURE_DESC)) { - $modifiedColumns[':p' . $index++] = '`feature_desc`'; - } - if ($this->isColumnModified(OrderFeaturePeer::FEATURE_AV_DESC)) { - $modifiedColumns[':p' . $index++] = '`feature_av_desc`'; - } - if ($this->isColumnModified(OrderFeaturePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `order_feature` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`order_product_id`': - $stmt->bindValue($identifier, $this->order_product_id, PDO::PARAM_INT); - break; - case '`feature_desc`': - $stmt->bindValue($identifier, $this->feature_desc, PDO::PARAM_STR); - break; - case '`feature_av_desc`': - $stmt->bindValue($identifier, $this->feature_av_desc, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrderProduct !== null) { - if (!$this->aOrderProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrderProduct->getValidationFailures()); - } - } - - - if (($retval = OrderFeaturePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderFeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getOrderProductId(); - break; - case 2: - return $this->getFeatureDesc(); - break; - case 3: - return $this->getFeatureAvDesc(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderFeature'][$this->getPrimaryKey()] = true; - $keys = OrderFeaturePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getOrderProductId(), - $keys[2] => $this->getFeatureDesc(), - $keys[3] => $this->getFeatureAvDesc(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aOrderProduct) { - $result['OrderProduct'] = $this->aOrderProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderFeaturePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setOrderProductId($value); - break; - case 2: - $this->setFeatureDesc($value); - break; - case 3: - $this->setFeatureAvDesc($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = OrderFeaturePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setOrderProductId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setFeatureDesc($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setFeatureAvDesc($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderFeaturePeer::ID)) $criteria->add(OrderFeaturePeer::ID, $this->id); - if ($this->isColumnModified(OrderFeaturePeer::ORDER_PRODUCT_ID)) $criteria->add(OrderFeaturePeer::ORDER_PRODUCT_ID, $this->order_product_id); - if ($this->isColumnModified(OrderFeaturePeer::FEATURE_DESC)) $criteria->add(OrderFeaturePeer::FEATURE_DESC, $this->feature_desc); - if ($this->isColumnModified(OrderFeaturePeer::FEATURE_AV_DESC)) $criteria->add(OrderFeaturePeer::FEATURE_AV_DESC, $this->feature_av_desc); - if ($this->isColumnModified(OrderFeaturePeer::CREATED_AT)) $criteria->add(OrderFeaturePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderFeaturePeer::UPDATED_AT)) $criteria->add(OrderFeaturePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - $criteria->add(OrderFeaturePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of OrderFeature (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setOrderProductId($this->getOrderProductId()); - $copyObj->setFeatureDesc($this->getFeatureDesc()); - $copyObj->setFeatureAvDesc($this->getFeatureAvDesc()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return OrderFeature Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return OrderFeaturePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderFeaturePeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a OrderProduct object. - * - * @param OrderProduct $v - * @return OrderFeature The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderProduct(OrderProduct $v = null) - { - if ($v === null) { - $this->setOrderProductId(NULL); - } else { - $this->setOrderProductId($v->getId()); - } - - $this->aOrderProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the OrderProduct object, it will not be re-added. - if ($v !== null) { - $v->addOrderFeature($this); - } - - - return $this; - } - - - /** - * Get the associated OrderProduct object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderProduct The associated OrderProduct object. - * @throws PropelException - */ - public function getOrderProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrderProduct === null && ($this->order_product_id !== null) && $doQuery) { - $this->aOrderProduct = OrderProductQuery::create()->findPk($this->order_product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderProduct->addOrderFeatures($this); - */ - } - - return $this->aOrderProduct; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->order_product_id = null; - $this->feature_desc = null; - $this->feature_av_desc = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aOrderProduct instanceof Persistent) { - $this->aOrderProduct->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aOrderProduct = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderFeaturePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return OrderFeature The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderFeaturePeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php b/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php deleted file mode 100755 index a8cc553ad..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderFeaturePeer.php +++ /dev/null @@ -1,1034 +0,0 @@ - array ('Id', 'OrderProductId', 'FeatureDesc', 'FeatureAvDesc', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderProductId', 'featureDesc', 'featureAvDesc', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (OrderFeaturePeer::ID, OrderFeaturePeer::ORDER_PRODUCT_ID, OrderFeaturePeer::FEATURE_DESC, OrderFeaturePeer::FEATURE_AV_DESC, OrderFeaturePeer::CREATED_AT, OrderFeaturePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_PRODUCT_ID', 'FEATURE_DESC', 'FEATURE_AV_DESC', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'order_product_id', 'feature_desc', 'feature_av_desc', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderFeaturePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderProductId' => 1, 'FeatureDesc' => 2, 'FeatureAvDesc' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderProductId' => 1, 'featureDesc' => 2, 'featureAvDesc' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (OrderFeaturePeer::ID => 0, OrderFeaturePeer::ORDER_PRODUCT_ID => 1, OrderFeaturePeer::FEATURE_DESC => 2, OrderFeaturePeer::FEATURE_AV_DESC => 3, OrderFeaturePeer::CREATED_AT => 4, OrderFeaturePeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'FEATURE_DESC' => 2, 'FEATURE_AV_DESC' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_product_id' => 1, 'feature_desc' => 2, 'feature_av_desc' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderFeaturePeer::getFieldNames($toType); - $key = isset(OrderFeaturePeer::$fieldKeys[$fromType][$name]) ? OrderFeaturePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderFeaturePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, OrderFeaturePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return OrderFeaturePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. OrderFeaturePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderFeaturePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderFeaturePeer::ID); - $criteria->addSelectColumn(OrderFeaturePeer::ORDER_PRODUCT_ID); - $criteria->addSelectColumn(OrderFeaturePeer::FEATURE_DESC); - $criteria->addSelectColumn(OrderFeaturePeer::FEATURE_AV_DESC); - $criteria->addSelectColumn(OrderFeaturePeer::CREATED_AT); - $criteria->addSelectColumn(OrderFeaturePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.order_product_id'); - $criteria->addSelectColumn($alias . '.feature_desc'); - $criteria->addSelectColumn($alias . '.feature_av_desc'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderFeaturePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return OrderFeature - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = OrderFeaturePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return OrderFeaturePeer::populateObjects(OrderFeaturePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderFeaturePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param OrderFeature $obj A OrderFeature object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - OrderFeaturePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A OrderFeature object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof OrderFeature) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderFeature object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderFeaturePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return OrderFeature Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(OrderFeaturePeer::$instances[$key])) { - return OrderFeaturePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderFeaturePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderFeaturePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order_feature - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderFeaturePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderFeaturePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (OrderFeature object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + OrderFeaturePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderFeaturePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderFeaturePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderProduct table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrderProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderFeaturePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of OrderFeature objects pre-filled with their OrderProduct objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of OrderFeature objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrderProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - } - - OrderFeaturePeer::addSelectColumns($criteria); - $startcol = OrderFeaturePeer::NUM_HYDRATE_COLUMNS; - OrderProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderFeaturePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderFeaturePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderFeaturePeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (OrderFeature) to $obj2 (OrderProduct) - $obj2->addOrderFeature($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderFeaturePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of OrderFeature objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of OrderFeature objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - } - - OrderFeaturePeer::addSelectColumns($criteria); - $startcol2 = OrderFeaturePeer::NUM_HYDRATE_COLUMNS; - - OrderProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + OrderProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderFeaturePeer::ORDER_PRODUCT_ID, OrderProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderFeaturePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderFeaturePeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderFeaturePeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderFeaturePeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined OrderProduct rows - - $key2 = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = OrderProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - OrderProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (OrderFeature) to the collection in $obj2 (OrderProduct) - $obj2->addOrderFeature($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(OrderFeaturePeer::DATABASE_NAME)->getTable(OrderFeaturePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderFeaturePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderFeaturePeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderFeatureTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderFeaturePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a OrderFeature or Criteria object. - * - * @param mixed $values Criteria or OrderFeature object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from OrderFeature object - } - - if ($criteria->containsKey(OrderFeaturePeer::ID) && $criteria->keyContainsValue(OrderFeaturePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderFeaturePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a OrderFeature or Criteria object. - * - * @param mixed $values Criteria or OrderFeature object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderFeaturePeer::ID); - $value = $criteria->remove(OrderFeaturePeer::ID); - if ($value) { - $selectCriteria->add(OrderFeaturePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderFeaturePeer::TABLE_NAME); - } - - } else { // $values is OrderFeature object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order_feature table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(OrderFeaturePeer::TABLE_NAME, $con, OrderFeaturePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderFeaturePeer::clearInstancePool(); - OrderFeaturePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a OrderFeature or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderFeature object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - OrderFeaturePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof OrderFeature) { // it's a model object - // invalidate the cache for this single object - OrderFeaturePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - $criteria->add(OrderFeaturePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - OrderFeaturePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderFeaturePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - OrderFeaturePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given OrderFeature object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param OrderFeature $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(OrderFeaturePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderFeaturePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(OrderFeaturePeer::DATABASE_NAME, OrderFeaturePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return OrderFeature - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = OrderFeaturePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - $criteria->add(OrderFeaturePeer::ID, $pk); - - $v = OrderFeaturePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return OrderFeature[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(OrderFeaturePeer::DATABASE_NAME); - $criteria->add(OrderFeaturePeer::ID, $pks, Criteria::IN); - $objs = OrderFeaturePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseOrderFeaturePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderFeaturePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php b/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php deleted file mode 100755 index 41c1b48c5..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderFeatureQuery.php +++ /dev/null @@ -1,641 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderFeaturePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(OrderFeaturePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderFeature A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderFeature A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `order_product_id`, `feature_desc`, `feature_av_desc`, `created_at`, `updated_at` FROM `order_feature` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderFeature(); - $obj->hydrate($row); - OrderFeaturePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderFeature|OrderFeature[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|OrderFeature[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderFeaturePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderFeaturePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderFeaturePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderFeaturePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the order_product_id column - * - * Example usage: - * - * $query->filterByOrderProductId(1234); // WHERE order_product_id = 1234 - * $query->filterByOrderProductId(array(12, 34)); // WHERE order_product_id IN (12, 34) - * $query->filterByOrderProductId(array('min' => 12)); // WHERE order_product_id >= 12 - * $query->filterByOrderProductId(array('max' => 12)); // WHERE order_product_id <= 12 - * - * - * @see filterByOrderProduct() - * - * @param mixed $orderProductId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByOrderProductId($orderProductId = null, $comparison = null) - { - if (is_array($orderProductId)) { - $useMinMax = false; - if (isset($orderProductId['min'])) { - $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($orderProductId['max'])) { - $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProductId, $comparison); - } - - /** - * Filter the query on the feature_desc column - * - * Example usage: - * - * $query->filterByFeatureDesc('fooValue'); // WHERE feature_desc = 'fooValue' - * $query->filterByFeatureDesc('%fooValue%'); // WHERE feature_desc LIKE '%fooValue%' - * - * - * @param string $featureDesc The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByFeatureDesc($featureDesc = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($featureDesc)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $featureDesc)) { - $featureDesc = str_replace('*', '%', $featureDesc); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::FEATURE_DESC, $featureDesc, $comparison); - } - - /** - * Filter the query on the feature_av_desc column - * - * Example usage: - * - * $query->filterByFeatureAvDesc('fooValue'); // WHERE feature_av_desc = 'fooValue' - * $query->filterByFeatureAvDesc('%fooValue%'); // WHERE feature_av_desc LIKE '%fooValue%' - * - * - * @param string $featureAvDesc The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByFeatureAvDesc($featureAvDesc = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($featureAvDesc)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $featureAvDesc)) { - $featureAvDesc = str_replace('*', '%', $featureAvDesc); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::FEATURE_AV_DESC, $featureAvDesc, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related OrderProduct object - * - * @param OrderProduct|PropelObjectCollection $orderProduct The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderFeatureQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderProduct($orderProduct, $comparison = null) - { - if ($orderProduct instanceof OrderProduct) { - return $this - ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->getId(), $comparison); - } elseif ($orderProduct instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderFeaturePeer::ORDER_PRODUCT_ID, $orderProduct->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderProduct relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderProduct'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderProduct'); - } - - return $this; - } - - /** - * Use the OrderProduct relation OrderProduct object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query - */ - public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrderProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); - } - - /** - * Exclude object from result - * - * @param OrderFeature $orderFeature Object to remove from the list of results - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function prune($orderFeature = null) - { - if ($orderFeature) { - $this->addUsingAlias(OrderFeaturePeer::ID, $orderFeature->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderFeaturePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderFeaturePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderFeaturePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderFeaturePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderFeaturePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return OrderFeatureQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderFeaturePeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseOrderPeer.php b/core/lib/Thelia/Model/om/BaseOrderPeer.php deleted file mode 100755 index 671a6a757..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderPeer.php +++ /dev/null @@ -1,2640 +0,0 @@ - array ('Id', 'Ref', 'CustomerId', 'AddressInvoice', 'AddressDelivery', 'InvoiceDate', 'CurrencyId', 'CurrencyRate', 'Transaction', 'DeliveryNum', 'Invoice', 'Postage', 'Payment', 'Carrier', 'StatusId', 'Lang', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'ref', 'customerId', 'addressInvoice', 'addressDelivery', 'invoiceDate', 'currencyId', 'currencyRate', 'transaction', 'deliveryNum', 'invoice', 'postage', 'payment', 'carrier', 'statusId', 'lang', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (OrderPeer::ID, OrderPeer::REF, OrderPeer::CUSTOMER_ID, OrderPeer::ADDRESS_INVOICE, OrderPeer::ADDRESS_DELIVERY, OrderPeer::INVOICE_DATE, OrderPeer::CURRENCY_ID, OrderPeer::CURRENCY_RATE, OrderPeer::TRANSACTION, OrderPeer::DELIVERY_NUM, OrderPeer::INVOICE, OrderPeer::POSTAGE, OrderPeer::PAYMENT, OrderPeer::CARRIER, OrderPeer::STATUS_ID, OrderPeer::LANG, OrderPeer::CREATED_AT, OrderPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'REF', 'CUSTOMER_ID', 'ADDRESS_INVOICE', 'ADDRESS_DELIVERY', 'INVOICE_DATE', 'CURRENCY_ID', 'CURRENCY_RATE', 'TRANSACTION', 'DELIVERY_NUM', 'INVOICE', 'POSTAGE', 'PAYMENT', 'CARRIER', 'STATUS_ID', 'LANG', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'ref', 'customer_id', 'address_invoice', 'address_delivery', 'invoice_date', 'currency_id', 'currency_rate', 'transaction', 'delivery_num', 'invoice', 'postage', 'payment', 'carrier', 'status_id', 'lang', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Ref' => 1, 'CustomerId' => 2, 'AddressInvoice' => 3, 'AddressDelivery' => 4, 'InvoiceDate' => 5, 'CurrencyId' => 6, 'CurrencyRate' => 7, 'Transaction' => 8, 'DeliveryNum' => 9, 'Invoice' => 10, 'Postage' => 11, 'Payment' => 12, 'Carrier' => 13, 'StatusId' => 14, 'Lang' => 15, 'CreatedAt' => 16, 'UpdatedAt' => 17, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'ref' => 1, 'customerId' => 2, 'addressInvoice' => 3, 'addressDelivery' => 4, 'invoiceDate' => 5, 'currencyId' => 6, 'currencyRate' => 7, 'transaction' => 8, 'deliveryNum' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'statusId' => 14, 'lang' => 15, 'createdAt' => 16, 'updatedAt' => 17, ), - BasePeer::TYPE_COLNAME => array (OrderPeer::ID => 0, OrderPeer::REF => 1, OrderPeer::CUSTOMER_ID => 2, OrderPeer::ADDRESS_INVOICE => 3, OrderPeer::ADDRESS_DELIVERY => 4, OrderPeer::INVOICE_DATE => 5, OrderPeer::CURRENCY_ID => 6, OrderPeer::CURRENCY_RATE => 7, OrderPeer::TRANSACTION => 8, OrderPeer::DELIVERY_NUM => 9, OrderPeer::INVOICE => 10, OrderPeer::POSTAGE => 11, OrderPeer::PAYMENT => 12, OrderPeer::CARRIER => 13, OrderPeer::STATUS_ID => 14, OrderPeer::LANG => 15, OrderPeer::CREATED_AT => 16, OrderPeer::UPDATED_AT => 17, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'REF' => 1, 'CUSTOMER_ID' => 2, 'ADDRESS_INVOICE' => 3, 'ADDRESS_DELIVERY' => 4, 'INVOICE_DATE' => 5, 'CURRENCY_ID' => 6, 'CURRENCY_RATE' => 7, 'TRANSACTION' => 8, 'DELIVERY_NUM' => 9, 'INVOICE' => 10, 'POSTAGE' => 11, 'PAYMENT' => 12, 'CARRIER' => 13, 'STATUS_ID' => 14, 'LANG' => 15, 'CREATED_AT' => 16, 'UPDATED_AT' => 17, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'ref' => 1, 'customer_id' => 2, 'address_invoice' => 3, 'address_delivery' => 4, 'invoice_date' => 5, 'currency_id' => 6, 'currency_rate' => 7, 'transaction' => 8, 'delivery_num' => 9, 'invoice' => 10, 'postage' => 11, 'payment' => 12, 'carrier' => 13, 'status_id' => 14, 'lang' => 15, 'created_at' => 16, 'updated_at' => 17, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderPeer::getFieldNames($toType); - $key = isset(OrderPeer::$fieldKeys[$fromType][$name]) ? OrderPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, OrderPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return OrderPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. OrderPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderPeer::ID); - $criteria->addSelectColumn(OrderPeer::REF); - $criteria->addSelectColumn(OrderPeer::CUSTOMER_ID); - $criteria->addSelectColumn(OrderPeer::ADDRESS_INVOICE); - $criteria->addSelectColumn(OrderPeer::ADDRESS_DELIVERY); - $criteria->addSelectColumn(OrderPeer::INVOICE_DATE); - $criteria->addSelectColumn(OrderPeer::CURRENCY_ID); - $criteria->addSelectColumn(OrderPeer::CURRENCY_RATE); - $criteria->addSelectColumn(OrderPeer::TRANSACTION); - $criteria->addSelectColumn(OrderPeer::DELIVERY_NUM); - $criteria->addSelectColumn(OrderPeer::INVOICE); - $criteria->addSelectColumn(OrderPeer::POSTAGE); - $criteria->addSelectColumn(OrderPeer::PAYMENT); - $criteria->addSelectColumn(OrderPeer::CARRIER); - $criteria->addSelectColumn(OrderPeer::STATUS_ID); - $criteria->addSelectColumn(OrderPeer::LANG); - $criteria->addSelectColumn(OrderPeer::CREATED_AT); - $criteria->addSelectColumn(OrderPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.ref'); - $criteria->addSelectColumn($alias . '.customer_id'); - $criteria->addSelectColumn($alias . '.address_invoice'); - $criteria->addSelectColumn($alias . '.address_delivery'); - $criteria->addSelectColumn($alias . '.invoice_date'); - $criteria->addSelectColumn($alias . '.currency_id'); - $criteria->addSelectColumn($alias . '.currency_rate'); - $criteria->addSelectColumn($alias . '.transaction'); - $criteria->addSelectColumn($alias . '.delivery_num'); - $criteria->addSelectColumn($alias . '.invoice'); - $criteria->addSelectColumn($alias . '.postage'); - $criteria->addSelectColumn($alias . '.payment'); - $criteria->addSelectColumn($alias . '.carrier'); - $criteria->addSelectColumn($alias . '.status_id'); - $criteria->addSelectColumn($alias . '.lang'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Order - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = OrderPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return OrderPeer::populateObjects(OrderPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Order $obj A Order object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - OrderPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Order object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Order) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Order object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Order Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(OrderPeer::$instances[$key])) { - return OrderPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in OrderProductPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderProductPeer::clearInstancePool(); - // Invalidate objects in CouponOrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - CouponOrderPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Order object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + OrderPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Currency table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCurrency(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Customer table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrderAddressRelatedByAddressInvoice(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrderAddressRelatedByAddressDelivery(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderStatus table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrderStatus(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Order objects pre-filled with their Currency objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol = OrderPeer::NUM_HYDRATE_COLUMNS; - CurrencyPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Order) to $obj2 (Currency) - $obj2->addOrder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with their Customer objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol = OrderPeer::NUM_HYDRATE_COLUMNS; - CustomerPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CustomerPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CustomerPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Order) to $obj2 (Customer) - $obj2->addOrder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with their OrderAddress objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol = OrderPeer::NUM_HYDRATE_COLUMNS; - OrderAddressPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderAddressPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderAddressPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Order) to $obj2 (OrderAddress) - $obj2->addOrderRelatedByAddressInvoice($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with their OrderAddress objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol = OrderPeer::NUM_HYDRATE_COLUMNS; - OrderAddressPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderAddressPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderAddressPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Order) to $obj2 (OrderAddress) - $obj2->addOrderRelatedByAddressDelivery($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with their OrderStatus objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol = OrderPeer::NUM_HYDRATE_COLUMNS; - OrderStatusPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderStatusPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderStatusPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Order) to $obj2 (OrderStatus) - $obj2->addOrder($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Order objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CurrencyPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol7 = $startcol6 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Currency rows - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Currency) - $obj2->addOrder($obj1); - } // if joined row not null - - // Add objects for joined Customer rows - - $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CustomerPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CustomerPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CustomerPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Order) to the collection in $obj3 (Customer) - $obj3->addOrder($obj1); - } // if joined row not null - - // Add objects for joined OrderAddress rows - - $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderAddressPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderAddressPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress) - $obj4->addOrderRelatedByAddressInvoice($obj1); - } // if joined row not null - - // Add objects for joined OrderAddress rows - - $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = OrderAddressPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - OrderAddressPeer::addInstanceToPool($obj5, $key5); - } // if obj5 loaded - - // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress) - $obj5->addOrderRelatedByAddressDelivery($obj1); - } // if joined row not null - - // Add objects for joined OrderStatus rows - - $key6 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol6); - if ($key6 !== null) { - $obj6 = OrderStatusPeer::getInstanceFromPool($key6); - if (!$obj6) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj6 = new $cls(); - $obj6->hydrate($row, $startcol6); - OrderStatusPeer::addInstanceToPool($obj6, $key6); - } // if obj6 loaded - - // Add the $obj1 (Order) to the collection in $obj6 (OrderStatus) - $obj6->addOrder($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Currency table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCurrency(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Customer table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCustomer(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressInvoice table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptOrderAddressRelatedByAddressInvoice(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderAddressRelatedByAddressDelivery table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptOrderAddressRelatedByAddressDelivery(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderStatus table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptOrderStatus(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Order objects pre-filled with all related objects except Currency. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCurrency(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Customer rows - - $key2 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CustomerPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CustomerPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CustomerPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Customer) - $obj2->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = OrderAddressPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - OrderAddressPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress) - $obj3->addOrderRelatedByAddressInvoice($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderAddressPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderAddressPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress) - $obj4->addOrderRelatedByAddressDelivery($obj1); - - } // if joined row is not null - - // Add objects for joined OrderStatus rows - - $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = OrderStatusPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - OrderStatusPeer::addInstanceToPool($obj5, $key5); - } // if $obj5 already loaded - - // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus) - $obj5->addOrder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with all related objects except Customer. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCustomer(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CurrencyPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Currency rows - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Currency) - $obj2->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key3 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = OrderAddressPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - OrderAddressPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Order) to the collection in $obj3 (OrderAddress) - $obj3->addOrderRelatedByAddressInvoice($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderAddressPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderAddressPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress) - $obj4->addOrderRelatedByAddressDelivery($obj1); - - } // if joined row is not null - - // Add objects for joined OrderStatus rows - - $key5 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = OrderStatusPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - OrderStatusPeer::addInstanceToPool($obj5, $key5); - } // if $obj5 already loaded - - // Add the $obj1 (Order) to the collection in $obj5 (OrderStatus) - $obj5->addOrder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressInvoice. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptOrderAddressRelatedByAddressInvoice(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CurrencyPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Currency rows - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Currency) - $obj2->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined Customer rows - - $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CustomerPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CustomerPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CustomerPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Order) to the collection in $obj3 (Customer) - $obj3->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined OrderStatus rows - - $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderStatusPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderStatusPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus) - $obj4->addOrder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with all related objects except OrderAddressRelatedByAddressDelivery. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptOrderAddressRelatedByAddressDelivery(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CurrencyPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::STATUS_ID, OrderStatusPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Currency rows - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Currency) - $obj2->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined Customer rows - - $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CustomerPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CustomerPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CustomerPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Order) to the collection in $obj3 (Customer) - $obj3->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined OrderStatus rows - - $key4 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderStatusPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderStatusPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderStatus) - $obj4->addOrder($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Order objects pre-filled with all related objects except OrderStatus. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Order objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderPeer::DATABASE_NAME); - } - - OrderPeer::addSelectColumns($criteria); - $startcol2 = OrderPeer::NUM_HYDRATE_COLUMNS; - - CurrencyPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CurrencyPeer::NUM_HYDRATE_COLUMNS; - - CustomerPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CustomerPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - OrderAddressPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + OrderAddressPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderPeer::CURRENCY_ID, CurrencyPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::CUSTOMER_ID, CustomerPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_INVOICE, OrderAddressPeer::ID, $join_behavior); - - $criteria->addJoin(OrderPeer::ADDRESS_DELIVERY, OrderAddressPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Currency rows - - $key2 = CurrencyPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CurrencyPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CurrencyPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CurrencyPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Order) to the collection in $obj2 (Currency) - $obj2->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined Customer rows - - $key3 = CustomerPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CustomerPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CustomerPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CustomerPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Order) to the collection in $obj3 (Customer) - $obj3->addOrder($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key4 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = OrderAddressPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - OrderAddressPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Order) to the collection in $obj4 (OrderAddress) - $obj4->addOrderRelatedByAddressInvoice($obj1); - - } // if joined row is not null - - // Add objects for joined OrderAddress rows - - $key5 = OrderAddressPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = OrderAddressPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = OrderAddressPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - OrderAddressPeer::addInstanceToPool($obj5, $key5); - } // if $obj5 already loaded - - // Add the $obj1 (Order) to the collection in $obj5 (OrderAddress) - $obj5->addOrderRelatedByAddressDelivery($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(OrderPeer::DATABASE_NAME)->getTable(OrderPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderPeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Order or Criteria object. - * - * @param mixed $values Criteria or Order object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Order object - } - - if ($criteria->containsKey(OrderPeer::ID) && $criteria->keyContainsValue(OrderPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Order or Criteria object. - * - * @param mixed $values Criteria or Order object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderPeer::ID); - $value = $criteria->remove(OrderPeer::ID); - if ($value) { - $selectCriteria->add(OrderPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderPeer::TABLE_NAME); - } - - } else { // $values is Order object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(OrderPeer::TABLE_NAME, $con, OrderPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderPeer::clearInstancePool(); - OrderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Order or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Order object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - OrderPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Order) { // it's a model object - // invalidate the cache for this single object - OrderPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - $criteria->add(OrderPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - OrderPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - OrderPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Order object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Order $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(OrderPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(OrderPeer::DATABASE_NAME, OrderPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Order - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = OrderPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - $criteria->add(OrderPeer::ID, $pk); - - $v = OrderPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Order[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(OrderPeer::DATABASE_NAME); - $criteria->add(OrderPeer::ID, $pks, Criteria::IN); - $objs = OrderPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseOrderPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderProduct.php b/core/lib/Thelia/Model/om/BaseOrderProduct.php deleted file mode 100755 index 19c1993bc..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderProduct.php +++ /dev/null @@ -1,1880 +0,0 @@ -id; - } - - /** - * Get the [order_id] column value. - * - * @return int - */ - public function getOrderId() - { - return $this->order_id; - } - - /** - * Get the [product_ref] column value. - * - * @return string - */ - public function getProductRef() - { - return $this->product_ref; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [quantity] column value. - * - * @return double - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * Get the [price] column value. - * - * @return double - */ - public function getPrice() - { - return $this->price; - } - - /** - * Get the [tax] column value. - * - * @return double - */ - public function getTax() - { - return $this->tax; - } - - /** - * Get the [parent] column value. - * - * @return int - */ - public function getParent() - { - return $this->parent; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderProductPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [order_id] column. - * - * @param int $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setOrderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->order_id !== $v) { - $this->order_id = $v; - $this->modifiedColumns[] = OrderProductPeer::ORDER_ID; - } - - if ($this->aOrder !== null && $this->aOrder->getId() !== $v) { - $this->aOrder = null; - } - - - return $this; - } // setOrderId() - - /** - * Set the value of [product_ref] column. - * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setProductRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->product_ref !== $v) { - $this->product_ref = $v; - $this->modifiedColumns[] = OrderProductPeer::PRODUCT_REF; - } - - - return $this; - } // setProductRef() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = OrderProductPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = OrderProductPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = OrderProductPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [quantity] column. - * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setQuantity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->quantity !== $v) { - $this->quantity = $v; - $this->modifiedColumns[] = OrderProductPeer::QUANTITY; - } - - - return $this; - } // setQuantity() - - /** - * Set the value of [price] column. - * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setPrice($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->price !== $v) { - $this->price = $v; - $this->modifiedColumns[] = OrderProductPeer::PRICE; - } - - - return $this; - } // setPrice() - - /** - * Set the value of [tax] column. - * - * @param double $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setTax($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->tax !== $v) { - $this->tax = $v; - $this->modifiedColumns[] = OrderProductPeer::TAX; - } - - - return $this; - } // setTax() - - /** - * Set the value of [parent] column. - * - * @param int $v new value - * @return OrderProduct The current object (for fluent API support) - */ - public function setParent($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->parent !== $v) { - $this->parent = $v; - $this->modifiedColumns[] = OrderProductPeer::PARENT; - } - - - return $this; - } // setParent() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderProduct The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = OrderProductPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderProduct The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = OrderProductPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->order_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->product_ref = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->title = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->chapo = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->quantity = ($row[$startcol + 6] !== null) ? (double) $row[$startcol + 6] : null; - $this->price = ($row[$startcol + 7] !== null) ? (double) $row[$startcol + 7] : null; - $this->tax = ($row[$startcol + 8] !== null) ? (double) $row[$startcol + 8] : null; - $this->parent = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; - $this->created_at = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; - $this->updated_at = ($row[$startcol + 11] !== null) ? (string) $row[$startcol + 11] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 12; // 12 = OrderProductPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating OrderProduct object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aOrder !== null && $this->order_id !== $this->aOrder->getId()) { - $this->aOrder = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = OrderProductPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aOrder = null; - $this->collOrderFeatures = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderProductQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderProductPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderProductPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderProductPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrder !== null) { - if ($this->aOrder->isModified() || $this->aOrder->isNew()) { - $affectedRows += $this->aOrder->save($con); - } - $this->setOrder($this->aOrder); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->orderFeaturesScheduledForDeletion !== null) { - if (!$this->orderFeaturesScheduledForDeletion->isEmpty()) { - OrderFeatureQuery::create() - ->filterByPrimaryKeys($this->orderFeaturesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->orderFeaturesScheduledForDeletion = null; - } - } - - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderProductPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderProductPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) { - $modifiedColumns[':p' . $index++] = '`order_id`'; - } - if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) { - $modifiedColumns[':p' . $index++] = '`product_ref`'; - } - if ($this->isColumnModified(OrderProductPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(OrderProductPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(OrderProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; - } - if ($this->isColumnModified(OrderProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`price`'; - } - if ($this->isColumnModified(OrderProductPeer::TAX)) { - $modifiedColumns[':p' . $index++] = '`tax`'; - } - if ($this->isColumnModified(OrderProductPeer::PARENT)) { - $modifiedColumns[':p' . $index++] = '`parent`'; - } - if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `order_product` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`order_id`': - $stmt->bindValue($identifier, $this->order_id, PDO::PARAM_INT); - break; - case '`product_ref`': - $stmt->bindValue($identifier, $this->product_ref, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`quantity`': - $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_STR); - break; - case '`price`': - $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); - break; - case '`tax`': - $stmt->bindValue($identifier, $this->tax, PDO::PARAM_STR); - break; - case '`parent`': - $stmt->bindValue($identifier, $this->parent, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrder !== null) { - if (!$this->aOrder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrder->getValidationFailures()); - } - } - - - if (($retval = OrderProductPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collOrderFeatures !== null) { - foreach ($this->collOrderFeatures as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getOrderId(); - break; - case 2: - return $this->getProductRef(); - break; - case 3: - return $this->getTitle(); - break; - case 4: - return $this->getDescription(); - break; - case 5: - return $this->getChapo(); - break; - case 6: - return $this->getQuantity(); - break; - case 7: - return $this->getPrice(); - break; - case 8: - return $this->getTax(); - break; - case 9: - return $this->getParent(); - break; - case 10: - return $this->getCreatedAt(); - break; - case 11: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderProduct'][$this->getPrimaryKey()] = true; - $keys = OrderProductPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getOrderId(), - $keys[2] => $this->getProductRef(), - $keys[3] => $this->getTitle(), - $keys[4] => $this->getDescription(), - $keys[5] => $this->getChapo(), - $keys[6] => $this->getQuantity(), - $keys[7] => $this->getPrice(), - $keys[8] => $this->getTax(), - $keys[9] => $this->getParent(), - $keys[10] => $this->getCreatedAt(), - $keys[11] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aOrder) { - $result['Order'] = $this->aOrder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collOrderFeatures) { - $result['OrderFeatures'] = $this->collOrderFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setOrderId($value); - break; - case 2: - $this->setProductRef($value); - break; - case 3: - $this->setTitle($value); - break; - case 4: - $this->setDescription($value); - break; - case 5: - $this->setChapo($value); - break; - case 6: - $this->setQuantity($value); - break; - case 7: - $this->setPrice($value); - break; - case 8: - $this->setTax($value); - break; - case 9: - $this->setParent($value); - break; - case 10: - $this->setCreatedAt($value); - break; - case 11: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = OrderProductPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setOrderId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductRef($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setTitle($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setDescription($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setChapo($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setQuantity($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPrice($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setTax($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setParent($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setCreatedAt($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setUpdatedAt($arr[$keys[11]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderProductPeer::ID)) $criteria->add(OrderProductPeer::ID, $this->id); - if ($this->isColumnModified(OrderProductPeer::ORDER_ID)) $criteria->add(OrderProductPeer::ORDER_ID, $this->order_id); - if ($this->isColumnModified(OrderProductPeer::PRODUCT_REF)) $criteria->add(OrderProductPeer::PRODUCT_REF, $this->product_ref); - if ($this->isColumnModified(OrderProductPeer::TITLE)) $criteria->add(OrderProductPeer::TITLE, $this->title); - if ($this->isColumnModified(OrderProductPeer::DESCRIPTION)) $criteria->add(OrderProductPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(OrderProductPeer::CHAPO)) $criteria->add(OrderProductPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(OrderProductPeer::QUANTITY)) $criteria->add(OrderProductPeer::QUANTITY, $this->quantity); - if ($this->isColumnModified(OrderProductPeer::PRICE)) $criteria->add(OrderProductPeer::PRICE, $this->price); - if ($this->isColumnModified(OrderProductPeer::TAX)) $criteria->add(OrderProductPeer::TAX, $this->tax); - if ($this->isColumnModified(OrderProductPeer::PARENT)) $criteria->add(OrderProductPeer::PARENT, $this->parent); - if ($this->isColumnModified(OrderProductPeer::CREATED_AT)) $criteria->add(OrderProductPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderProductPeer::UPDATED_AT)) $criteria->add(OrderProductPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - $criteria->add(OrderProductPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of OrderProduct (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setOrderId($this->getOrderId()); - $copyObj->setProductRef($this->getProductRef()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setQuantity($this->getQuantity()); - $copyObj->setPrice($this->getPrice()); - $copyObj->setTax($this->getTax()); - $copyObj->setParent($this->getParent()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getOrderFeatures() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderFeature($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return OrderProduct Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return OrderProductPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderProductPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Order object. - * - * @param Order $v - * @return OrderProduct The current object (for fluent API support) - * @throws PropelException - */ - public function setOrder(Order $v = null) - { - if ($v === null) { - $this->setOrderId(NULL); - } else { - $this->setOrderId($v->getId()); - } - - $this->aOrder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Order object, it will not be re-added. - if ($v !== null) { - $v->addOrderProduct($this); - } - - - return $this; - } - - - /** - * Get the associated Order object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Order The associated Order object. - * @throws PropelException - */ - public function getOrder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrder === null && ($this->order_id !== null) && $doQuery) { - $this->aOrder = OrderQuery::create()->findPk($this->order_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrder->addOrderProducts($this); - */ - } - - return $this->aOrder; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('OrderFeature' == $relationName) { - $this->initOrderFeatures(); - } - } - - /** - * Clears out the collOrderFeatures collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return OrderProduct The current object (for fluent API support) - * @see addOrderFeatures() - */ - public function clearOrderFeatures() - { - $this->collOrderFeatures = null; // important to set this to null since that means it is uninitialized - $this->collOrderFeaturesPartial = null; - - return $this; - } - - /** - * reset is the collOrderFeatures collection loaded partially - * - * @return void - */ - public function resetPartialOrderFeatures($v = true) - { - $this->collOrderFeaturesPartial = $v; - } - - /** - * Initializes the collOrderFeatures collection. - * - * By default this just sets the collOrderFeatures collection to an empty array (like clearcollOrderFeatures()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrderFeatures($overrideExisting = true) - { - if (null !== $this->collOrderFeatures && !$overrideExisting) { - return; - } - $this->collOrderFeatures = new PropelObjectCollection(); - $this->collOrderFeatures->setModel('OrderFeature'); - } - - /** - * Gets an array of OrderFeature objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this OrderProduct is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|OrderFeature[] List of OrderFeature objects - * @throws PropelException - */ - public function getOrderFeatures($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { - // return empty collection - $this->initOrderFeatures(); - } else { - $collOrderFeatures = OrderFeatureQuery::create(null, $criteria) - ->filterByOrderProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrderFeaturesPartial && count($collOrderFeatures)) { - $this->initOrderFeatures(false); - - foreach($collOrderFeatures as $obj) { - if (false == $this->collOrderFeatures->contains($obj)) { - $this->collOrderFeatures->append($obj); - } - } - - $this->collOrderFeaturesPartial = true; - } - - $collOrderFeatures->getInternalIterator()->rewind(); - return $collOrderFeatures; - } - - if($partial && $this->collOrderFeatures) { - foreach($this->collOrderFeatures as $obj) { - if($obj->isNew()) { - $collOrderFeatures[] = $obj; - } - } - } - - $this->collOrderFeatures = $collOrderFeatures; - $this->collOrderFeaturesPartial = false; - } - } - - return $this->collOrderFeatures; - } - - /** - * Sets a collection of OrderFeature objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $orderFeatures A Propel collection. - * @param PropelPDO $con Optional connection object - * @return OrderProduct The current object (for fluent API support) - */ - public function setOrderFeatures(PropelCollection $orderFeatures, PropelPDO $con = null) - { - $orderFeaturesToDelete = $this->getOrderFeatures(new Criteria(), $con)->diff($orderFeatures); - - $this->orderFeaturesScheduledForDeletion = unserialize(serialize($orderFeaturesToDelete)); - - foreach ($orderFeaturesToDelete as $orderFeatureRemoved) { - $orderFeatureRemoved->setOrderProduct(null); - } - - $this->collOrderFeatures = null; - foreach ($orderFeatures as $orderFeature) { - $this->addOrderFeature($orderFeature); - } - - $this->collOrderFeatures = $orderFeatures; - $this->collOrderFeaturesPartial = false; - - return $this; - } - - /** - * Returns the number of related OrderFeature objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related OrderFeature objects. - * @throws PropelException - */ - public function countOrderFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrderFeaturesPartial && !$this->isNew(); - if (null === $this->collOrderFeatures || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderFeatures) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrderFeatures()); - } - $query = OrderFeatureQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderProduct($this) - ->count($con); - } - - return count($this->collOrderFeatures); - } - - /** - * Method called to associate a OrderFeature object to this object - * through the OrderFeature foreign key attribute. - * - * @param OrderFeature $l OrderFeature - * @return OrderProduct The current object (for fluent API support) - */ - public function addOrderFeature(OrderFeature $l) - { - if ($this->collOrderFeatures === null) { - $this->initOrderFeatures(); - $this->collOrderFeaturesPartial = true; - } - if (!in_array($l, $this->collOrderFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderFeature($l); - } - - return $this; - } - - /** - * @param OrderFeature $orderFeature The orderFeature object to add. - */ - protected function doAddOrderFeature($orderFeature) - { - $this->collOrderFeatures[]= $orderFeature; - $orderFeature->setOrderProduct($this); - } - - /** - * @param OrderFeature $orderFeature The orderFeature object to remove. - * @return OrderProduct The current object (for fluent API support) - */ - public function removeOrderFeature($orderFeature) - { - if ($this->getOrderFeatures()->contains($orderFeature)) { - $this->collOrderFeatures->remove($this->collOrderFeatures->search($orderFeature)); - if (null === $this->orderFeaturesScheduledForDeletion) { - $this->orderFeaturesScheduledForDeletion = clone $this->collOrderFeatures; - $this->orderFeaturesScheduledForDeletion->clear(); - } - $this->orderFeaturesScheduledForDeletion[]= clone $orderFeature; - $orderFeature->setOrderProduct(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->order_id = null; - $this->product_ref = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->quantity = null; - $this->price = null; - $this->tax = null; - $this->parent = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collOrderFeatures) { - foreach ($this->collOrderFeatures as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aOrder instanceof Persistent) { - $this->aOrder->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - if ($this->collOrderFeatures instanceof PropelCollection) { - $this->collOrderFeatures->clearIterator(); - } - $this->collOrderFeatures = null; - $this->aOrder = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderProductPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return OrderProduct The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderProductPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php b/core/lib/Thelia/Model/om/BaseOrderProductPeer.php deleted file mode 100755 index f0e91ddff..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderProductPeer.php +++ /dev/null @@ -1,1068 +0,0 @@ - array ('Id', 'OrderId', 'ProductRef', 'Title', 'Description', 'Chapo', 'Quantity', 'Price', 'Tax', 'Parent', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'orderId', 'productRef', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (OrderProductPeer::ID, OrderProductPeer::ORDER_ID, OrderProductPeer::PRODUCT_REF, OrderProductPeer::TITLE, OrderProductPeer::DESCRIPTION, OrderProductPeer::CHAPO, OrderProductPeer::QUANTITY, OrderProductPeer::PRICE, OrderProductPeer::TAX, OrderProductPeer::PARENT, OrderProductPeer::CREATED_AT, OrderProductPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'ORDER_ID', 'PRODUCT_REF', 'TITLE', 'DESCRIPTION', 'CHAPO', 'QUANTITY', 'PRICE', 'TAX', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'order_id', 'product_ref', 'title', 'description', 'chapo', 'quantity', 'price', 'tax', 'parent', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'Title' => 3, 'Description' => 4, 'Chapo' => 5, 'Quantity' => 6, 'Price' => 7, 'Tax' => 8, 'Parent' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'orderId' => 1, 'productRef' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - BasePeer::TYPE_COLNAME => array (OrderProductPeer::ID => 0, OrderProductPeer::ORDER_ID => 1, OrderProductPeer::PRODUCT_REF => 2, OrderProductPeer::TITLE => 3, OrderProductPeer::DESCRIPTION => 4, OrderProductPeer::CHAPO => 5, OrderProductPeer::QUANTITY => 6, OrderProductPeer::PRICE => 7, OrderProductPeer::TAX => 8, OrderProductPeer::PARENT => 9, OrderProductPeer::CREATED_AT => 10, OrderProductPeer::UPDATED_AT => 11, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'TITLE' => 3, 'DESCRIPTION' => 4, 'CHAPO' => 5, 'QUANTITY' => 6, 'PRICE' => 7, 'TAX' => 8, 'PARENT' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'title' => 3, 'description' => 4, 'chapo' => 5, 'quantity' => 6, 'price' => 7, 'tax' => 8, 'parent' => 9, 'created_at' => 10, 'updated_at' => 11, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderProductPeer::getFieldNames($toType); - $key = isset(OrderProductPeer::$fieldKeys[$fromType][$name]) ? OrderProductPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderProductPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, OrderProductPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return OrderProductPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. OrderProductPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderProductPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderProductPeer::ID); - $criteria->addSelectColumn(OrderProductPeer::ORDER_ID); - $criteria->addSelectColumn(OrderProductPeer::PRODUCT_REF); - $criteria->addSelectColumn(OrderProductPeer::TITLE); - $criteria->addSelectColumn(OrderProductPeer::DESCRIPTION); - $criteria->addSelectColumn(OrderProductPeer::CHAPO); - $criteria->addSelectColumn(OrderProductPeer::QUANTITY); - $criteria->addSelectColumn(OrderProductPeer::PRICE); - $criteria->addSelectColumn(OrderProductPeer::TAX); - $criteria->addSelectColumn(OrderProductPeer::PARENT); - $criteria->addSelectColumn(OrderProductPeer::CREATED_AT); - $criteria->addSelectColumn(OrderProductPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.order_id'); - $criteria->addSelectColumn($alias . '.product_ref'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.quantity'); - $criteria->addSelectColumn($alias . '.price'); - $criteria->addSelectColumn($alias . '.tax'); - $criteria->addSelectColumn($alias . '.parent'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return OrderProduct - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = OrderProductPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return OrderProductPeer::populateObjects(OrderProductPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderProductPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param OrderProduct $obj A OrderProduct object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - OrderProductPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A OrderProduct object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof OrderProduct) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderProduct object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderProductPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return OrderProduct Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(OrderProductPeer::$instances[$key])) { - return OrderProductPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderProductPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderProductPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order_product - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in OrderFeaturePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderFeaturePeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderProductPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderProductPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderProductPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (OrderProduct object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderProductPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + OrderProductPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderProductPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderProductPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Order table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of OrderProduct objects pre-filled with their Order objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of OrderProduct objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - } - - OrderProductPeer::addSelectColumns($criteria); - $startcol = OrderProductPeer::NUM_HYDRATE_COLUMNS; - OrderPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderProductPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderProductPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderProductPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (OrderProduct) to $obj2 (Order) - $obj2->addOrderProduct($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of OrderProduct objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of OrderProduct objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - } - - OrderProductPeer::addSelectColumns($criteria); - $startcol2 = OrderProductPeer::NUM_HYDRATE_COLUMNS; - - OrderPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + OrderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderProductPeer::ORDER_ID, OrderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderProductPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderProductPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderProductPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Order rows - - $key2 = OrderPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = OrderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - OrderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (OrderProduct) to the collection in $obj2 (Order) - $obj2->addOrderProduct($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(OrderProductPeer::DATABASE_NAME)->getTable(OrderProductPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderProductPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderProductPeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderProductTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderProductPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a OrderProduct or Criteria object. - * - * @param mixed $values Criteria or OrderProduct object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from OrderProduct object - } - - if ($criteria->containsKey(OrderProductPeer::ID) && $criteria->keyContainsValue(OrderProductPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderProductPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a OrderProduct or Criteria object. - * - * @param mixed $values Criteria or OrderProduct object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderProductPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderProductPeer::ID); - $value = $criteria->remove(OrderProductPeer::ID); - if ($value) { - $selectCriteria->add(OrderProductPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderProductPeer::TABLE_NAME); - } - - } else { // $values is OrderProduct object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order_product table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(OrderProductPeer::TABLE_NAME, $con, OrderProductPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderProductPeer::clearInstancePool(); - OrderProductPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a OrderProduct or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderProduct object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - OrderProductPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof OrderProduct) { // it's a model object - // invalidate the cache for this single object - OrderProductPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - $criteria->add(OrderProductPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - OrderProductPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderProductPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - OrderProductPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given OrderProduct object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param OrderProduct $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(OrderProductPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderProductPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(OrderProductPeer::DATABASE_NAME, OrderProductPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return OrderProduct - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = OrderProductPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - $criteria->add(OrderProductPeer::ID, $pk); - - $v = OrderProductPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return OrderProduct[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(OrderProductPeer::DATABASE_NAME); - $criteria->add(OrderProductPeer::ID, $pks, Criteria::IN); - $objs = OrderProductPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseOrderProductPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderProductPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php b/core/lib/Thelia/Model/om/BaseOrderProductQuery.php deleted file mode 100755 index b93c39cce..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderProductQuery.php +++ /dev/null @@ -1,970 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderProductPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(OrderProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderProduct A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderProduct A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `order_id`, `product_ref`, `title`, `description`, `chapo`, `quantity`, `price`, `tax`, `parent`, `created_at`, `updated_at` FROM `order_product` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderProduct(); - $obj->hydrate($row); - OrderProductPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderProduct|OrderProduct[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|OrderProduct[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderProductPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderProductPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderProductPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the order_id column - * - * Example usage: - * - * $query->filterByOrderId(1234); // WHERE order_id = 1234 - * $query->filterByOrderId(array(12, 34)); // WHERE order_id IN (12, 34) - * $query->filterByOrderId(array('min' => 12)); // WHERE order_id >= 12 - * $query->filterByOrderId(array('max' => 12)); // WHERE order_id <= 12 - * - * - * @see filterByOrder() - * - * @param mixed $orderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByOrderId($orderId = null, $comparison = null) - { - if (is_array($orderId)) { - $useMinMax = false; - if (isset($orderId['min'])) { - $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($orderId['max'])) { - $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::ORDER_ID, $orderId, $comparison); - } - - /** - * Filter the query on the product_ref column - * - * Example usage: - * - * $query->filterByProductRef('fooValue'); // WHERE product_ref = 'fooValue' - * $query->filterByProductRef('%fooValue%'); // WHERE product_ref LIKE '%fooValue%' - * - * - * @param string $productRef The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByProductRef($productRef = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($productRef)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $productRef)) { - $productRef = str_replace('*', '%', $productRef); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductPeer::PRODUCT_REF, $productRef, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderProductPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the quantity column - * - * Example usage: - * - * $query->filterByQuantity(1234); // WHERE quantity = 1234 - * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) - * $query->filterByQuantity(array('min' => 12)); // WHERE quantity >= 12 - * $query->filterByQuantity(array('max' => 12)); // WHERE quantity <= 12 - * - * - * @param mixed $quantity The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByQuantity($quantity = null, $comparison = null) - { - if (is_array($quantity)) { - $useMinMax = false; - if (isset($quantity['min'])) { - $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($quantity['max'])) { - $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::QUANTITY, $quantity, $comparison); - } - - /** - * Filter the query on the price column - * - * Example usage: - * - * $query->filterByPrice(1234); // WHERE price = 1234 - * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) - * $query->filterByPrice(array('min' => 12)); // WHERE price >= 12 - * $query->filterByPrice(array('max' => 12)); // WHERE price <= 12 - * - * - * @param mixed $price The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByPrice($price = null, $comparison = null) - { - if (is_array($price)) { - $useMinMax = false; - if (isset($price['min'])) { - $this->addUsingAlias(OrderProductPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($price['max'])) { - $this->addUsingAlias(OrderProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::PRICE, $price, $comparison); - } - - /** - * Filter the query on the tax column - * - * Example usage: - * - * $query->filterByTax(1234); // WHERE tax = 1234 - * $query->filterByTax(array(12, 34)); // WHERE tax IN (12, 34) - * $query->filterByTax(array('min' => 12)); // WHERE tax >= 12 - * $query->filterByTax(array('max' => 12)); // WHERE tax <= 12 - * - * - * @param mixed $tax The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByTax($tax = null, $comparison = null) - { - if (is_array($tax)) { - $useMinMax = false; - if (isset($tax['min'])) { - $this->addUsingAlias(OrderProductPeer::TAX, $tax['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($tax['max'])) { - $this->addUsingAlias(OrderProductPeer::TAX, $tax['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::TAX, $tax, $comparison); - } - - /** - * Filter the query on the parent column - * - * Example usage: - * - * $query->filterByParent(1234); // WHERE parent = 1234 - * $query->filterByParent(array(12, 34)); // WHERE parent IN (12, 34) - * $query->filterByParent(array('min' => 12)); // WHERE parent >= 12 - * $query->filterByParent(array('max' => 12)); // WHERE parent <= 12 - * - * - * @param mixed $parent The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByParent($parent = null, $comparison = null) - { - if (is_array($parent)) { - $useMinMax = false; - if (isset($parent['min'])) { - $this->addUsingAlias(OrderProductPeer::PARENT, $parent['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($parent['max'])) { - $this->addUsingAlias(OrderProductPeer::PARENT, $parent['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::PARENT, $parent, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->getId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderProductPeer::ORDER_ID, $order->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Filter the query by a related OrderFeature object - * - * @param OrderFeature|PropelObjectCollection $orderFeature the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderFeature($orderFeature, $comparison = null) - { - if ($orderFeature instanceof OrderFeature) { - return $this - ->addUsingAlias(OrderProductPeer::ID, $orderFeature->getOrderProductId(), $comparison); - } elseif ($orderFeature instanceof PropelObjectCollection) { - return $this - ->useOrderFeatureQuery() - ->filterByPrimaryKeys($orderFeature->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderFeature() only accepts arguments of type OrderFeature or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderFeature relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function joinOrderFeature($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderFeature'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderFeature'); - } - - return $this; - } - - /** - * Use the OrderFeature relation OrderFeature object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderFeatureQuery A secondary query class using the current class as primary query - */ - public function useOrderFeatureQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrderFeature($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderFeature', '\Thelia\Model\OrderFeatureQuery'); - } - - /** - * Exclude object from result - * - * @param OrderProduct $orderProduct Object to remove from the list of results - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function prune($orderProduct = null) - { - if ($orderProduct) { - $this->addUsingAlias(OrderProductPeer::ID, $orderProduct->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderProductPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderProductPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderProductPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderProductPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderProductPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return OrderProductQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderProductPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseOrderQuery.php b/core/lib/Thelia/Model/om/BaseOrderQuery.php deleted file mode 100755 index c0e630548..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderQuery.php +++ /dev/null @@ -1,1618 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Order|Order[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(OrderPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Order A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Order A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `ref`, `customer_id`, `address_invoice`, `address_delivery`, `invoice_date`, `currency_id`, `currency_rate`, `transaction`, `delivery_num`, `invoice`, `postage`, `payment`, `carrier`, `status_id`, `lang`, `created_at`, `updated_at` FROM `order` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Order(); - $obj->hydrate($row); - OrderPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Order|Order[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Order[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the ref column - * - * Example usage: - * - * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue' - * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%' - * - * - * @param string $ref The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByRef($ref = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($ref)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $ref)) { - $ref = str_replace('*', '%', $ref); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::REF, $ref, $comparison); - } - - /** - * Filter the query on the customer_id column - * - * Example usage: - * - * $query->filterByCustomerId(1234); // WHERE customer_id = 1234 - * $query->filterByCustomerId(array(12, 34)); // WHERE customer_id IN (12, 34) - * $query->filterByCustomerId(array('min' => 12)); // WHERE customer_id >= 12 - * $query->filterByCustomerId(array('max' => 12)); // WHERE customer_id <= 12 - * - * - * @see filterByCustomer() - * - * @param mixed $customerId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByCustomerId($customerId = null, $comparison = null) - { - if (is_array($customerId)) { - $useMinMax = false; - if (isset($customerId['min'])) { - $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($customerId['max'])) { - $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::CUSTOMER_ID, $customerId, $comparison); - } - - /** - * Filter the query on the address_invoice column - * - * Example usage: - * - * $query->filterByAddressInvoice(1234); // WHERE address_invoice = 1234 - * $query->filterByAddressInvoice(array(12, 34)); // WHERE address_invoice IN (12, 34) - * $query->filterByAddressInvoice(array('min' => 12)); // WHERE address_invoice >= 12 - * $query->filterByAddressInvoice(array('max' => 12)); // WHERE address_invoice <= 12 - * - * - * @see filterByOrderAddressRelatedByAddressInvoice() - * - * @param mixed $addressInvoice The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByAddressInvoice($addressInvoice = null, $comparison = null) - { - if (is_array($addressInvoice)) { - $useMinMax = false; - if (isset($addressInvoice['min'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($addressInvoice['max'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $addressInvoice, $comparison); - } - - /** - * Filter the query on the address_delivery column - * - * Example usage: - * - * $query->filterByAddressDelivery(1234); // WHERE address_delivery = 1234 - * $query->filterByAddressDelivery(array(12, 34)); // WHERE address_delivery IN (12, 34) - * $query->filterByAddressDelivery(array('min' => 12)); // WHERE address_delivery >= 12 - * $query->filterByAddressDelivery(array('max' => 12)); // WHERE address_delivery <= 12 - * - * - * @see filterByOrderAddressRelatedByAddressDelivery() - * - * @param mixed $addressDelivery The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByAddressDelivery($addressDelivery = null, $comparison = null) - { - if (is_array($addressDelivery)) { - $useMinMax = false; - if (isset($addressDelivery['min'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($addressDelivery['max'])) { - $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $addressDelivery, $comparison); - } - - /** - * Filter the query on the invoice_date column - * - * Example usage: - * - * $query->filterByInvoiceDate('2011-03-14'); // WHERE invoice_date = '2011-03-14' - * $query->filterByInvoiceDate('now'); // WHERE invoice_date = '2011-03-14' - * $query->filterByInvoiceDate(array('max' => 'yesterday')); // WHERE invoice_date > '2011-03-13' - * - * - * @param mixed $invoiceDate The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByInvoiceDate($invoiceDate = null, $comparison = null) - { - if (is_array($invoiceDate)) { - $useMinMax = false; - if (isset($invoiceDate['min'])) { - $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($invoiceDate['max'])) { - $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::INVOICE_DATE, $invoiceDate, $comparison); - } - - /** - * Filter the query on the currency_id column - * - * Example usage: - * - * $query->filterByCurrencyId(1234); // WHERE currency_id = 1234 - * $query->filterByCurrencyId(array(12, 34)); // WHERE currency_id IN (12, 34) - * $query->filterByCurrencyId(array('min' => 12)); // WHERE currency_id >= 12 - * $query->filterByCurrencyId(array('max' => 12)); // WHERE currency_id <= 12 - * - * - * @see filterByCurrency() - * - * @param mixed $currencyId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByCurrencyId($currencyId = null, $comparison = null) - { - if (is_array($currencyId)) { - $useMinMax = false; - if (isset($currencyId['min'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($currencyId['max'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::CURRENCY_ID, $currencyId, $comparison); - } - - /** - * Filter the query on the currency_rate column - * - * Example usage: - * - * $query->filterByCurrencyRate(1234); // WHERE currency_rate = 1234 - * $query->filterByCurrencyRate(array(12, 34)); // WHERE currency_rate IN (12, 34) - * $query->filterByCurrencyRate(array('min' => 12)); // WHERE currency_rate >= 12 - * $query->filterByCurrencyRate(array('max' => 12)); // WHERE currency_rate <= 12 - * - * - * @param mixed $currencyRate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByCurrencyRate($currencyRate = null, $comparison = null) - { - if (is_array($currencyRate)) { - $useMinMax = false; - if (isset($currencyRate['min'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($currencyRate['max'])) { - $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::CURRENCY_RATE, $currencyRate, $comparison); - } - - /** - * Filter the query on the transaction column - * - * Example usage: - * - * $query->filterByTransaction('fooValue'); // WHERE transaction = 'fooValue' - * $query->filterByTransaction('%fooValue%'); // WHERE transaction LIKE '%fooValue%' - * - * - * @param string $transaction The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByTransaction($transaction = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($transaction)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $transaction)) { - $transaction = str_replace('*', '%', $transaction); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::TRANSACTION, $transaction, $comparison); - } - - /** - * Filter the query on the delivery_num column - * - * Example usage: - * - * $query->filterByDeliveryNum('fooValue'); // WHERE delivery_num = 'fooValue' - * $query->filterByDeliveryNum('%fooValue%'); // WHERE delivery_num LIKE '%fooValue%' - * - * - * @param string $deliveryNum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByDeliveryNum($deliveryNum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($deliveryNum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $deliveryNum)) { - $deliveryNum = str_replace('*', '%', $deliveryNum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::DELIVERY_NUM, $deliveryNum, $comparison); - } - - /** - * Filter the query on the invoice column - * - * Example usage: - * - * $query->filterByInvoice('fooValue'); // WHERE invoice = 'fooValue' - * $query->filterByInvoice('%fooValue%'); // WHERE invoice LIKE '%fooValue%' - * - * - * @param string $invoice The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByInvoice($invoice = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($invoice)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $invoice)) { - $invoice = str_replace('*', '%', $invoice); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::INVOICE, $invoice, $comparison); - } - - /** - * Filter the query on the postage column - * - * Example usage: - * - * $query->filterByPostage(1234); // WHERE postage = 1234 - * $query->filterByPostage(array(12, 34)); // WHERE postage IN (12, 34) - * $query->filterByPostage(array('min' => 12)); // WHERE postage >= 12 - * $query->filterByPostage(array('max' => 12)); // WHERE postage <= 12 - * - * - * @param mixed $postage The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByPostage($postage = null, $comparison = null) - { - if (is_array($postage)) { - $useMinMax = false; - if (isset($postage['min'])) { - $this->addUsingAlias(OrderPeer::POSTAGE, $postage['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($postage['max'])) { - $this->addUsingAlias(OrderPeer::POSTAGE, $postage['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::POSTAGE, $postage, $comparison); - } - - /** - * Filter the query on the payment column - * - * Example usage: - * - * $query->filterByPayment('fooValue'); // WHERE payment = 'fooValue' - * $query->filterByPayment('%fooValue%'); // WHERE payment LIKE '%fooValue%' - * - * - * @param string $payment The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByPayment($payment = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($payment)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $payment)) { - $payment = str_replace('*', '%', $payment); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::PAYMENT, $payment, $comparison); - } - - /** - * Filter the query on the carrier column - * - * Example usage: - * - * $query->filterByCarrier('fooValue'); // WHERE carrier = 'fooValue' - * $query->filterByCarrier('%fooValue%'); // WHERE carrier LIKE '%fooValue%' - * - * - * @param string $carrier The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByCarrier($carrier = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($carrier)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $carrier)) { - $carrier = str_replace('*', '%', $carrier); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::CARRIER, $carrier, $comparison); - } - - /** - * Filter the query on the status_id column - * - * Example usage: - * - * $query->filterByStatusId(1234); // WHERE status_id = 1234 - * $query->filterByStatusId(array(12, 34)); // WHERE status_id IN (12, 34) - * $query->filterByStatusId(array('min' => 12)); // WHERE status_id >= 12 - * $query->filterByStatusId(array('max' => 12)); // WHERE status_id <= 12 - * - * - * @see filterByOrderStatus() - * - * @param mixed $statusId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByStatusId($statusId = null, $comparison = null) - { - if (is_array($statusId)) { - $useMinMax = false; - if (isset($statusId['min'])) { - $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($statusId['max'])) { - $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::STATUS_ID, $statusId, $comparison); - } - - /** - * Filter the query on the lang column - * - * Example usage: - * - * $query->filterByLang('fooValue'); // WHERE lang = 'fooValue' - * $query->filterByLang('%fooValue%'); // WHERE lang LIKE '%fooValue%' - * - * - * @param string $lang The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByLang($lang = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($lang)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $lang)) { - $lang = str_replace('*', '%', $lang); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderPeer::LANG, $lang, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Currency object - * - * @param Currency|PropelObjectCollection $currency The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCurrency($currency, $comparison = null) - { - if ($currency instanceof Currency) { - return $this - ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->getId(), $comparison); - } elseif ($currency instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderPeer::CURRENCY_ID, $currency->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCurrency() only accepts arguments of type Currency or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Currency relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinCurrency($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Currency'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Currency'); - } - - return $this; - } - - /** - * Use the Currency relation Currency object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CurrencyQuery A secondary query class using the current class as primary query - */ - public function useCurrencyQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCurrency($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Currency', '\Thelia\Model\CurrencyQuery'); - } - - /** - * Filter the query by a related Customer object - * - * @param Customer|PropelObjectCollection $customer The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCustomer($customer, $comparison = null) - { - if ($customer instanceof Customer) { - return $this - ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->getId(), $comparison); - } elseif ($customer instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderPeer::CUSTOMER_ID, $customer->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCustomer() only accepts arguments of type Customer or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Customer relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinCustomer($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Customer'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Customer'); - } - - return $this; - } - - /** - * Use the Customer relation Customer object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CustomerQuery A secondary query class using the current class as primary query - */ - public function useCustomerQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCustomer($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Customer', '\Thelia\Model\CustomerQuery'); - } - - /** - * Filter the query by a related OrderAddress object - * - * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderAddressRelatedByAddressInvoice($orderAddress, $comparison = null) - { - if ($orderAddress instanceof OrderAddress) { - return $this - ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->getId(), $comparison); - } elseif ($orderAddress instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderPeer::ADDRESS_INVOICE, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderAddressRelatedByAddressInvoice() only accepts arguments of type OrderAddress or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressInvoice relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinOrderAddressRelatedByAddressInvoice($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressInvoice'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressInvoice'); - } - - return $this; - } - - /** - * Use the OrderAddressRelatedByAddressInvoice relation OrderAddress object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query - */ - public function useOrderAddressRelatedByAddressInvoiceQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrderAddressRelatedByAddressInvoice($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressInvoice', '\Thelia\Model\OrderAddressQuery'); - } - - /** - * Filter the query by a related OrderAddress object - * - * @param OrderAddress|PropelObjectCollection $orderAddress The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderAddressRelatedByAddressDelivery($orderAddress, $comparison = null) - { - if ($orderAddress instanceof OrderAddress) { - return $this - ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->getId(), $comparison); - } elseif ($orderAddress instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderPeer::ADDRESS_DELIVERY, $orderAddress->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderAddressRelatedByAddressDelivery() only accepts arguments of type OrderAddress or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderAddressRelatedByAddressDelivery relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinOrderAddressRelatedByAddressDelivery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderAddressRelatedByAddressDelivery'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderAddressRelatedByAddressDelivery'); - } - - return $this; - } - - /** - * Use the OrderAddressRelatedByAddressDelivery relation OrderAddress object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderAddressQuery A secondary query class using the current class as primary query - */ - public function useOrderAddressRelatedByAddressDeliveryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrderAddressRelatedByAddressDelivery($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderAddressRelatedByAddressDelivery', '\Thelia\Model\OrderAddressQuery'); - } - - /** - * Filter the query by a related OrderStatus object - * - * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderStatus($orderStatus, $comparison = null) - { - if ($orderStatus instanceof OrderStatus) { - return $this - ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->getId(), $comparison); - } elseif ($orderStatus instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderPeer::STATUS_ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderStatus relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinOrderStatus($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderStatus'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderStatus'); - } - - return $this; - } - - /** - * Use the OrderStatus relation OrderStatus object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query - */ - public function useOrderStatusQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrderStatus($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery'); - } - - /** - * Filter the query by a related OrderProduct object - * - * @param OrderProduct|PropelObjectCollection $orderProduct the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderProduct($orderProduct, $comparison = null) - { - if ($orderProduct instanceof OrderProduct) { - return $this - ->addUsingAlias(OrderPeer::ID, $orderProduct->getOrderId(), $comparison); - } elseif ($orderProduct instanceof PropelObjectCollection) { - return $this - ->useOrderProductQuery() - ->filterByPrimaryKeys($orderProduct->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderProduct() only accepts arguments of type OrderProduct or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderProduct relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinOrderProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderProduct'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderProduct'); - } - - return $this; - } - - /** - * Use the OrderProduct relation OrderProduct object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderProductQuery A secondary query class using the current class as primary query - */ - public function useOrderProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinOrderProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderProduct', '\Thelia\Model\OrderProductQuery'); - } - - /** - * Filter the query by a related CouponOrder object - * - * @param CouponOrder|PropelObjectCollection $couponOrder the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCouponOrder($couponOrder, $comparison = null) - { - if ($couponOrder instanceof CouponOrder) { - return $this - ->addUsingAlias(OrderPeer::ID, $couponOrder->getOrderId(), $comparison); - } elseif ($couponOrder instanceof PropelObjectCollection) { - return $this - ->useCouponOrderQuery() - ->filterByPrimaryKeys($couponOrder->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByCouponOrder() only accepts arguments of type CouponOrder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the CouponOrder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderQuery The current query, for fluid interface - */ - public function joinCouponOrder($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('CouponOrder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'CouponOrder'); - } - - return $this; - } - - /** - * Use the CouponOrder relation CouponOrder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CouponOrderQuery A secondary query class using the current class as primary query - */ - public function useCouponOrderQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCouponOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'CouponOrder', '\Thelia\Model\CouponOrderQuery'); - } - - /** - * Exclude object from result - * - * @param Order $order Object to remove from the list of results - * - * @return OrderQuery The current query, for fluid interface - */ - public function prune($order = null) - { - if ($order) { - $this->addUsingAlias(OrderPeer::ID, $order->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return OrderQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return OrderQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return OrderQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return OrderQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return OrderQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return OrderQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseOrderStatus.php b/core/lib/Thelia/Model/om/BaseOrderStatus.php deleted file mode 100755 index 2654069e2..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatus.php +++ /dev/null @@ -1,1940 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return OrderStatus The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderStatusPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return OrderStatus The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = OrderStatusPeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderStatus The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = OrderStatusPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return OrderStatus The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = OrderStatusPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = OrderStatusPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating OrderStatus object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = OrderStatusPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collOrders = null; - - $this->collOrderStatusI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderStatusQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(OrderStatusPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - OrderStatusPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->ordersScheduledForDeletion !== null) { - if (!$this->ordersScheduledForDeletion->isEmpty()) { - foreach ($this->ordersScheduledForDeletion as $order) { - // need to save related object because we set the relation to null - $order->save($con); - } - $this->ordersScheduledForDeletion = null; - } - } - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->orderStatusI18nsScheduledForDeletion !== null) { - if (!$this->orderStatusI18nsScheduledForDeletion->isEmpty()) { - OrderStatusI18nQuery::create() - ->filterByPrimaryKeys($this->orderStatusI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->orderStatusI18nsScheduledForDeletion = null; - } - } - - if ($this->collOrderStatusI18ns !== null) { - foreach ($this->collOrderStatusI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = OrderStatusPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . OrderStatusPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderStatusPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderStatusPeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `order_status` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = OrderStatusPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collOrders !== null) { - foreach ($this->collOrders as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collOrderStatusI18ns !== null) { - foreach ($this->collOrderStatusI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderStatus'][$this->getPrimaryKey()] = true; - $keys = OrderStatusPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collOrders) { - $result['Orders'] = $this->collOrders->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collOrderStatusI18ns) { - $result['OrderStatusI18ns'] = $this->collOrderStatusI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderStatusPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = OrderStatusPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderStatusPeer::ID)) $criteria->add(OrderStatusPeer::ID, $this->id); - if ($this->isColumnModified(OrderStatusPeer::CODE)) $criteria->add(OrderStatusPeer::CODE, $this->code); - if ($this->isColumnModified(OrderStatusPeer::CREATED_AT)) $criteria->add(OrderStatusPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(OrderStatusPeer::UPDATED_AT)) $criteria->add(OrderStatusPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - $criteria->add(OrderStatusPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of OrderStatus (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getOrders() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrder($relObj->copy($deepCopy)); - } - } - - foreach ($this->getOrderStatusI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addOrderStatusI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return OrderStatus Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return OrderStatusPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderStatusPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Order' == $relationName) { - $this->initOrders(); - } - if ('OrderStatusI18n' == $relationName) { - $this->initOrderStatusI18ns(); - } - } - - /** - * Clears out the collOrders collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return OrderStatus The current object (for fluent API support) - * @see addOrders() - */ - public function clearOrders() - { - $this->collOrders = null; // important to set this to null since that means it is uninitialized - $this->collOrdersPartial = null; - - return $this; - } - - /** - * reset is the collOrders collection loaded partially - * - * @return void - */ - public function resetPartialOrders($v = true) - { - $this->collOrdersPartial = $v; - } - - /** - * Initializes the collOrders collection. - * - * By default this just sets the collOrders collection to an empty array (like clearcollOrders()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initOrders($overrideExisting = true) - { - if (null !== $this->collOrders && !$overrideExisting) { - return; - } - $this->collOrders = new PropelObjectCollection(); - $this->collOrders->setModel('Order'); - } - - /** - * Gets an array of Order objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this OrderStatus is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Order[] List of Order objects - * @throws PropelException - */ - public function getOrders($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - // return empty collection - $this->initOrders(); - } else { - $collOrders = OrderQuery::create(null, $criteria) - ->filterByOrderStatus($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrdersPartial && count($collOrders)) { - $this->initOrders(false); - - foreach($collOrders as $obj) { - if (false == $this->collOrders->contains($obj)) { - $this->collOrders->append($obj); - } - } - - $this->collOrdersPartial = true; - } - - $collOrders->getInternalIterator()->rewind(); - return $collOrders; - } - - if($partial && $this->collOrders) { - foreach($this->collOrders as $obj) { - if($obj->isNew()) { - $collOrders[] = $obj; - } - } - } - - $this->collOrders = $collOrders; - $this->collOrdersPartial = false; - } - } - - return $this->collOrders; - } - - /** - * Sets a collection of Order objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $orders A Propel collection. - * @param PropelPDO $con Optional connection object - * @return OrderStatus The current object (for fluent API support) - */ - public function setOrders(PropelCollection $orders, PropelPDO $con = null) - { - $ordersToDelete = $this->getOrders(new Criteria(), $con)->diff($orders); - - $this->ordersScheduledForDeletion = unserialize(serialize($ordersToDelete)); - - foreach ($ordersToDelete as $orderRemoved) { - $orderRemoved->setOrderStatus(null); - } - - $this->collOrders = null; - foreach ($orders as $order) { - $this->addOrder($order); - } - - $this->collOrders = $orders; - $this->collOrdersPartial = false; - - return $this; - } - - /** - * Returns the number of related Order objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Order objects. - * @throws PropelException - */ - public function countOrders(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrdersPartial && !$this->isNew(); - if (null === $this->collOrders || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrders) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrders()); - } - $query = OrderQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderStatus($this) - ->count($con); - } - - return count($this->collOrders); - } - - /** - * Method called to associate a Order object to this object - * through the Order foreign key attribute. - * - * @param Order $l Order - * @return OrderStatus The current object (for fluent API support) - */ - public function addOrder(Order $l) - { - if ($this->collOrders === null) { - $this->initOrders(); - $this->collOrdersPartial = true; - } - if (!in_array($l, $this->collOrders->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrder($l); - } - - return $this; - } - - /** - * @param Order $order The order object to add. - */ - protected function doAddOrder($order) - { - $this->collOrders[]= $order; - $order->setOrderStatus($this); - } - - /** - * @param Order $order The order object to remove. - * @return OrderStatus The current object (for fluent API support) - */ - public function removeOrder($order) - { - if ($this->getOrders()->contains($order)) { - $this->collOrders->remove($this->collOrders->search($order)); - if (null === $this->ordersScheduledForDeletion) { - $this->ordersScheduledForDeletion = clone $this->collOrders; - $this->ordersScheduledForDeletion->clear(); - } - $this->ordersScheduledForDeletion[]= $order; - $order->setOrderStatus(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderStatus is new, it will return - * an empty collection; or if this OrderStatus has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderStatus. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinCurrency($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Currency', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderStatus is new, it will return - * an empty collection; or if this OrderStatus has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderStatus. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('Customer', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderStatus is new, it will return - * an empty collection; or if this OrderStatus has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderStatus. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressInvoice($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressInvoice', $join_behavior); - - return $this->getOrders($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this OrderStatus is new, it will return - * an empty collection; or if this OrderStatus has previously - * been saved, it will retrieve related Orders from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in OrderStatus. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Order[] List of Order objects - */ - public function getOrdersJoinOrderAddressRelatedByAddressDelivery($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = OrderQuery::create(null, $criteria); - $query->joinWith('OrderAddressRelatedByAddressDelivery', $join_behavior); - - return $this->getOrders($query, $con); - } - - /** - * Clears out the collOrderStatusI18ns 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 OrderStatus The current object (for fluent API support) - * @see addOrderStatusI18ns() - */ - public function clearOrderStatusI18ns() - { - $this->collOrderStatusI18ns = null; // important to set this to null since that means it is uninitialized - $this->collOrderStatusI18nsPartial = null; - - return $this; - } - - /** - * reset is the collOrderStatusI18ns collection loaded partially - * - * @return void - */ - public function resetPartialOrderStatusI18ns($v = true) - { - $this->collOrderStatusI18nsPartial = $v; - } - - /** - * Initializes the collOrderStatusI18ns collection. - * - * By default this just sets the collOrderStatusI18ns collection to an empty array (like clearcollOrderStatusI18ns()); - * 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 initOrderStatusI18ns($overrideExisting = true) - { - if (null !== $this->collOrderStatusI18ns && !$overrideExisting) { - return; - } - $this->collOrderStatusI18ns = new PropelObjectCollection(); - $this->collOrderStatusI18ns->setModel('OrderStatusI18n'); - } - - /** - * Gets an array of OrderStatusI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this OrderStatus is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|OrderStatusI18n[] List of OrderStatusI18n objects - * @throws PropelException - */ - public function getOrderStatusI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collOrderStatusI18nsPartial && !$this->isNew(); - if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderStatusI18ns) { - // return empty collection - $this->initOrderStatusI18ns(); - } else { - $collOrderStatusI18ns = OrderStatusI18nQuery::create(null, $criteria) - ->filterByOrderStatus($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collOrderStatusI18nsPartial && count($collOrderStatusI18ns)) { - $this->initOrderStatusI18ns(false); - - foreach($collOrderStatusI18ns as $obj) { - if (false == $this->collOrderStatusI18ns->contains($obj)) { - $this->collOrderStatusI18ns->append($obj); - } - } - - $this->collOrderStatusI18nsPartial = true; - } - - $collOrderStatusI18ns->getInternalIterator()->rewind(); - return $collOrderStatusI18ns; - } - - if($partial && $this->collOrderStatusI18ns) { - foreach($this->collOrderStatusI18ns as $obj) { - if($obj->isNew()) { - $collOrderStatusI18ns[] = $obj; - } - } - } - - $this->collOrderStatusI18ns = $collOrderStatusI18ns; - $this->collOrderStatusI18nsPartial = false; - } - } - - return $this->collOrderStatusI18ns; - } - - /** - * Sets a collection of OrderStatusI18n 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 $orderStatusI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return OrderStatus The current object (for fluent API support) - */ - public function setOrderStatusI18ns(PropelCollection $orderStatusI18ns, PropelPDO $con = null) - { - $orderStatusI18nsToDelete = $this->getOrderStatusI18ns(new Criteria(), $con)->diff($orderStatusI18ns); - - $this->orderStatusI18nsScheduledForDeletion = unserialize(serialize($orderStatusI18nsToDelete)); - - foreach ($orderStatusI18nsToDelete as $orderStatusI18nRemoved) { - $orderStatusI18nRemoved->setOrderStatus(null); - } - - $this->collOrderStatusI18ns = null; - foreach ($orderStatusI18ns as $orderStatusI18n) { - $this->addOrderStatusI18n($orderStatusI18n); - } - - $this->collOrderStatusI18ns = $orderStatusI18ns; - $this->collOrderStatusI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related OrderStatusI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related OrderStatusI18n objects. - * @throws PropelException - */ - public function countOrderStatusI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collOrderStatusI18nsPartial && !$this->isNew(); - if (null === $this->collOrderStatusI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collOrderStatusI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getOrderStatusI18ns()); - } - $query = OrderStatusI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByOrderStatus($this) - ->count($con); - } - - return count($this->collOrderStatusI18ns); - } - - /** - * Method called to associate a OrderStatusI18n object to this object - * through the OrderStatusI18n foreign key attribute. - * - * @param OrderStatusI18n $l OrderStatusI18n - * @return OrderStatus The current object (for fluent API support) - */ - public function addOrderStatusI18n(OrderStatusI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collOrderStatusI18ns === null) { - $this->initOrderStatusI18ns(); - $this->collOrderStatusI18nsPartial = true; - } - if (!in_array($l, $this->collOrderStatusI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddOrderStatusI18n($l); - } - - return $this; - } - - /** - * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to add. - */ - protected function doAddOrderStatusI18n($orderStatusI18n) - { - $this->collOrderStatusI18ns[]= $orderStatusI18n; - $orderStatusI18n->setOrderStatus($this); - } - - /** - * @param OrderStatusI18n $orderStatusI18n The orderStatusI18n object to remove. - * @return OrderStatus The current object (for fluent API support) - */ - public function removeOrderStatusI18n($orderStatusI18n) - { - if ($this->getOrderStatusI18ns()->contains($orderStatusI18n)) { - $this->collOrderStatusI18ns->remove($this->collOrderStatusI18ns->search($orderStatusI18n)); - if (null === $this->orderStatusI18nsScheduledForDeletion) { - $this->orderStatusI18nsScheduledForDeletion = clone $this->collOrderStatusI18ns; - $this->orderStatusI18nsScheduledForDeletion->clear(); - } - $this->orderStatusI18nsScheduledForDeletion[]= clone $orderStatusI18n; - $orderStatusI18n->setOrderStatus(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collOrders) { - foreach ($this->collOrders as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collOrderStatusI18ns) { - foreach ($this->collOrderStatusI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collOrders instanceof PropelCollection) { - $this->collOrders->clearIterator(); - } - $this->collOrders = null; - if ($this->collOrderStatusI18ns instanceof PropelCollection) { - $this->collOrderStatusI18ns->clearIterator(); - } - $this->collOrderStatusI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderStatusPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return OrderStatus The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = OrderStatusPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return OrderStatus The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return OrderStatusI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collOrderStatusI18ns) { - foreach ($this->collOrderStatusI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new OrderStatusI18n(); - $translation->setLocale($locale); - } else { - $translation = OrderStatusI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addOrderStatusI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return OrderStatus The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - OrderStatusI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collOrderStatusI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collOrderStatusI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return OrderStatusI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php deleted file mode 100755 index 976b1d0af..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseOrderStatusI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::ID; - } - - if ($this->aOrderStatus !== null && $this->aOrderStatus->getId() !== $v) { - $this->aOrderStatus = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return OrderStatusI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = OrderStatusI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = OrderStatusI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating OrderStatusI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aOrderStatus !== null && $this->id !== $this->aOrderStatus->getId()) { - $this->aOrderStatus = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::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 = OrderStatusI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aOrderStatus = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = OrderStatusI18nQuery::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(OrderStatusI18nPeer::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); - OrderStatusI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrderStatus !== null) { - if ($this->aOrderStatus->isModified() || $this->aOrderStatus->isNew()) { - $affectedRows += $this->aOrderStatus->save($con); - } - $this->setOrderStatus($this->aOrderStatus); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(OrderStatusI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(OrderStatusI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(OrderStatusI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(OrderStatusI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(OrderStatusI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(OrderStatusI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `order_status_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aOrderStatus !== null) { - if (!$this->aOrderStatus->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aOrderStatus->getValidationFailures()); - } - } - - - if (($retval = OrderStatusI18nPeer::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 = OrderStatusI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['OrderStatusI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['OrderStatusI18n'][serialize($this->getPrimaryKey())] = true; - $keys = OrderStatusI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aOrderStatus) { - $result['OrderStatus'] = $this->aOrderStatus->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = OrderStatusI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = OrderStatusI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(OrderStatusI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(OrderStatusI18nPeer::ID)) $criteria->add(OrderStatusI18nPeer::ID, $this->id); - if ($this->isColumnModified(OrderStatusI18nPeer::LOCALE)) $criteria->add(OrderStatusI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(OrderStatusI18nPeer::TITLE)) $criteria->add(OrderStatusI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(OrderStatusI18nPeer::DESCRIPTION)) $criteria->add(OrderStatusI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(OrderStatusI18nPeer::CHAPO)) $criteria->add(OrderStatusI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(OrderStatusI18nPeer::POSTSCRIPTUM)) $criteria->add(OrderStatusI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(OrderStatusI18nPeer::DATABASE_NAME); - $criteria->add(OrderStatusI18nPeer::ID, $this->id); - $criteria->add(OrderStatusI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 OrderStatusI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 OrderStatusI18n 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 OrderStatusI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new OrderStatusI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a OrderStatus object. - * - * @param OrderStatus $v - * @return OrderStatusI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setOrderStatus(OrderStatus $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aOrderStatus = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the OrderStatus object, it will not be re-added. - if ($v !== null) { - $v->addOrderStatusI18n($this); - } - - - return $this; - } - - - /** - * Get the associated OrderStatus object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return OrderStatus The associated OrderStatus object. - * @throws PropelException - */ - public function getOrderStatus(PropelPDO $con = null, $doQuery = true) - { - if ($this->aOrderStatus === null && ($this->id !== null) && $doQuery) { - $this->aOrderStatus = OrderStatusQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aOrderStatus->addOrderStatusI18ns($this); - */ - } - - return $this->aOrderStatus; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aOrderStatus instanceof Persistent) { - $this->aOrderStatus->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aOrderStatus = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(OrderStatusI18nPeer::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/BaseOrderStatusI18nPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php deleted file mode 100755 index 2c44a0b2d..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (OrderStatusI18nPeer::ID, OrderStatusI18nPeer::LOCALE, OrderStatusI18nPeer::TITLE, OrderStatusI18nPeer::DESCRIPTION, OrderStatusI18nPeer::CHAPO, OrderStatusI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderStatusI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (OrderStatusI18nPeer::ID => 0, OrderStatusI18nPeer::LOCALE => 1, OrderStatusI18nPeer::TITLE => 2, OrderStatusI18nPeer::DESCRIPTION => 3, OrderStatusI18nPeer::CHAPO => 4, OrderStatusI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderStatusI18nPeer::getFieldNames($toType); - $key = isset(OrderStatusI18nPeer::$fieldKeys[$fromType][$name]) ? OrderStatusI18nPeer::$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(OrderStatusI18nPeer::$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, OrderStatusI18nPeer::$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 OrderStatusI18nPeer::$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. OrderStatusI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderStatusI18nPeer::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(OrderStatusI18nPeer::ID); - $criteria->addSelectColumn(OrderStatusI18nPeer::LOCALE); - $criteria->addSelectColumn(OrderStatusI18nPeer::TITLE); - $criteria->addSelectColumn(OrderStatusI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(OrderStatusI18nPeer::CHAPO); - $criteria->addSelectColumn(OrderStatusI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(OrderStatusI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderStatusI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderStatusI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::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 OrderStatusI18n - * @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 = OrderStatusI18nPeer::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 OrderStatusI18nPeer::populateObjects(OrderStatusI18nPeer::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 directly (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(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderStatusI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::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 OrderStatusI18n $obj A OrderStatusI18n 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->getLocale())); - } // if key === null - OrderStatusI18nPeer::$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 OrderStatusI18n 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 OrderStatusI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 OrderStatusI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderStatusI18nPeer::$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 OrderStatusI18n 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(OrderStatusI18nPeer::$instances[$key])) { - return OrderStatusI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderStatusI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderStatusI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order_status_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderStatusI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderStatusI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderStatusI18nPeer::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; - OrderStatusI18nPeer::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 (OrderStatusI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderStatusI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderStatusI18nPeer::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 + OrderStatusI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderStatusI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderStatusI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related OrderStatus table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinOrderStatus(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderStatusI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderStatusI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderStatusI18nPeer::ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of OrderStatusI18n objects pre-filled with their OrderStatus objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of OrderStatusI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinOrderStatus(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(OrderStatusI18nPeer::DATABASE_NAME); - } - - OrderStatusI18nPeer::addSelectColumns($criteria); - $startcol = OrderStatusI18nPeer::NUM_HYDRATE_COLUMNS; - OrderStatusPeer::addSelectColumns($criteria); - - $criteria->addJoin(OrderStatusI18nPeer::ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderStatusI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderStatusI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = OrderStatusI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderStatusI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = OrderStatusPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - OrderStatusPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (OrderStatusI18n) to $obj2 (OrderStatus) - $obj2->addOrderStatusI18n($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(OrderStatusI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderStatusI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(OrderStatusI18nPeer::ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of OrderStatusI18n 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 OrderStatusI18n 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(OrderStatusI18nPeer::DATABASE_NAME); - } - - OrderStatusI18nPeer::addSelectColumns($criteria); - $startcol2 = OrderStatusI18nPeer::NUM_HYDRATE_COLUMNS; - - OrderStatusPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(OrderStatusI18nPeer::ID, OrderStatusPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = OrderStatusI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = OrderStatusI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = OrderStatusI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - OrderStatusI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined OrderStatus rows - - $key2 = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = OrderStatusPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = OrderStatusPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - OrderStatusPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (OrderStatusI18n) to the collection in $obj2 (OrderStatus) - $obj2->addOrderStatusI18n($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(OrderStatusI18nPeer::DATABASE_NAME)->getTable(OrderStatusI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderStatusI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderStatusI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderStatusI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderStatusI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a OrderStatusI18n or Criteria object. - * - * @param mixed $values Criteria or OrderStatusI18n 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(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from OrderStatusI18n object - } - - - // Set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::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 OrderStatusI18n or Criteria object. - * - * @param mixed $values Criteria or OrderStatusI18n 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(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderStatusI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderStatusI18nPeer::ID); - $value = $criteria->remove(OrderStatusI18nPeer::ID); - if ($value) { - $selectCriteria->add(OrderStatusI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderStatusI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(OrderStatusI18nPeer::LOCALE); - $value = $criteria->remove(OrderStatusI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(OrderStatusI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderStatusI18nPeer::TABLE_NAME); - } - - } else { // $values is OrderStatusI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order_status_i18n 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(OrderStatusI18nPeer::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(OrderStatusI18nPeer::TABLE_NAME, $con, OrderStatusI18nPeer::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). - OrderStatusI18nPeer::clearInstancePool(); - OrderStatusI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a OrderStatusI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderStatusI18n 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(OrderStatusI18nPeer::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. - OrderStatusI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof OrderStatusI18n) { // it's a model object - // invalidate the cache for this single object - OrderStatusI18nPeer::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(OrderStatusI18nPeer::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(OrderStatusI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(OrderStatusI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - OrderStatusI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderStatusI18nPeer::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); - OrderStatusI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given OrderStatusI18n 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 OrderStatusI18n $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(OrderStatusI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderStatusI18nPeer::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(OrderStatusI18nPeer::DATABASE_NAME, OrderStatusI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return OrderStatusI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = OrderStatusI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(OrderStatusI18nPeer::DATABASE_NAME); - $criteria->add(OrderStatusI18nPeer::ID, $id); - $criteria->add(OrderStatusI18nPeer::LOCALE, $locale); - $v = OrderStatusI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseOrderStatusI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderStatusI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php deleted file mode 100755 index 33eddef85..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatusI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return OrderStatusI18n|OrderStatusI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderStatusI18nPeer::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(OrderStatusI18nPeer::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 OrderStatusI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `order_status_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 OrderStatusI18n(); - $obj->hydrate($row); - OrderStatusI18nPeer::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 OrderStatusI18n|OrderStatusI18n[]|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|OrderStatusI18n[]|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 OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(OrderStatusI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(OrderStatusI18nPeer::LOCALE, $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 OrderStatusI18nQuery 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(OrderStatusI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(OrderStatusI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByOrderStatus() - * - * @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 OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderStatusI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderStatusI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related OrderStatus object - * - * @param OrderStatus|PropelObjectCollection $orderStatus The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderStatus($orderStatus, $comparison = null) - { - if ($orderStatus instanceof OrderStatus) { - return $this - ->addUsingAlias(OrderStatusI18nPeer::ID, $orderStatus->getId(), $comparison); - } elseif ($orderStatus instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(OrderStatusI18nPeer::ID, $orderStatus->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByOrderStatus() only accepts arguments of type OrderStatus or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderStatus relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function joinOrderStatus($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderStatus'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderStatus'); - } - - return $this; - } - - /** - * Use the OrderStatus relation OrderStatus object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderStatusQuery A secondary query class using the current class as primary query - */ - public function useOrderStatusQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinOrderStatus($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderStatus', '\Thelia\Model\OrderStatusQuery'); - } - - /** - * Exclude object from result - * - * @param OrderStatusI18n $orderStatusI18n Object to remove from the list of results - * - * @return OrderStatusI18nQuery The current query, for fluid interface - */ - public function prune($orderStatusI18n = null) - { - if ($orderStatusI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(OrderStatusI18nPeer::ID), $orderStatusI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(OrderStatusI18nPeer::LOCALE), $orderStatusI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php b/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php deleted file mode 100755 index 173f410c9..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatusPeer.php +++ /dev/null @@ -1,800 +0,0 @@ - array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (OrderStatusPeer::ID, OrderStatusPeer::CODE, OrderStatusPeer::CREATED_AT, OrderStatusPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. OrderStatusPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (OrderStatusPeer::ID => 0, OrderStatusPeer::CODE => 1, OrderStatusPeer::CREATED_AT => 2, OrderStatusPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = OrderStatusPeer::getFieldNames($toType); - $key = isset(OrderStatusPeer::$fieldKeys[$fromType][$name]) ? OrderStatusPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(OrderStatusPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, OrderStatusPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return OrderStatusPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. OrderStatusPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(OrderStatusPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(OrderStatusPeer::ID); - $criteria->addSelectColumn(OrderStatusPeer::CODE); - $criteria->addSelectColumn(OrderStatusPeer::CREATED_AT); - $criteria->addSelectColumn(OrderStatusPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - OrderStatusPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return OrderStatus - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = OrderStatusPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return OrderStatusPeer::populateObjects(OrderStatusPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - OrderStatusPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param OrderStatus $obj A OrderStatus object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - OrderStatusPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A OrderStatus object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof OrderStatus) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or OrderStatus object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(OrderStatusPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return OrderStatus Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(OrderStatusPeer::$instances[$key])) { - return OrderStatusPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (OrderStatusPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - OrderStatusPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to order_status - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in OrderPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderPeer::clearInstancePool(); - // Invalidate objects in OrderStatusI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - OrderStatusI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = OrderStatusPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = OrderStatusPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = OrderStatusPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - OrderStatusPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (OrderStatus object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = OrderStatusPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = OrderStatusPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + OrderStatusPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = OrderStatusPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - OrderStatusPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(OrderStatusPeer::DATABASE_NAME)->getTable(OrderStatusPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseOrderStatusPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseOrderStatusPeer::TABLE_NAME)) { - $dbMap->addTableObject(new OrderStatusTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return OrderStatusPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a OrderStatus or Criteria object. - * - * @param mixed $values Criteria or OrderStatus object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from OrderStatus object - } - - if ($criteria->containsKey(OrderStatusPeer::ID) && $criteria->keyContainsValue(OrderStatusPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.OrderStatusPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a OrderStatus or Criteria object. - * - * @param mixed $values Criteria or OrderStatus object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(OrderStatusPeer::ID); - $value = $criteria->remove(OrderStatusPeer::ID); - if ($value) { - $selectCriteria->add(OrderStatusPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(OrderStatusPeer::TABLE_NAME); - } - - } else { // $values is OrderStatus object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the order_status table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(OrderStatusPeer::TABLE_NAME, $con, OrderStatusPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - OrderStatusPeer::clearInstancePool(); - OrderStatusPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a OrderStatus or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or OrderStatus object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - OrderStatusPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof OrderStatus) { // it's a model object - // invalidate the cache for this single object - OrderStatusPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - $criteria->add(OrderStatusPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - OrderStatusPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(OrderStatusPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - OrderStatusPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given OrderStatus object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param OrderStatus $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(OrderStatusPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(OrderStatusPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(OrderStatusPeer::DATABASE_NAME, OrderStatusPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return OrderStatus - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = OrderStatusPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - $criteria->add(OrderStatusPeer::ID, $pk); - - $v = OrderStatusPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return OrderStatus[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(OrderStatusPeer::DATABASE_NAME); - $criteria->add(OrderStatusPeer::ID, $pks, Criteria::IN); - $objs = OrderStatusPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseOrderStatusPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseOrderStatusPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php b/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php deleted file mode 100755 index d8c1f3c7f..000000000 --- a/core/lib/Thelia/Model/om/BaseOrderStatusQuery.php +++ /dev/null @@ -1,694 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = OrderStatusPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(OrderStatusPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderStatus A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderStatus A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `order_status` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new OrderStatus(); - $obj->hydrate($row); - OrderStatusPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return OrderStatus|OrderStatus[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|OrderStatus[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(OrderStatusPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(OrderStatusPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(OrderStatusPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(OrderStatusPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderStatusPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(OrderStatusPeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Order object - * - * @param Order|PropelObjectCollection $order the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrder($order, $comparison = null) - { - if ($order instanceof Order) { - return $this - ->addUsingAlias(OrderStatusPeer::ID, $order->getStatusId(), $comparison); - } elseif ($order instanceof PropelObjectCollection) { - return $this - ->useOrderQuery() - ->filterByPrimaryKeys($order->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrder() only accepts arguments of type Order or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Order relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function joinOrder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Order'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Order'); - } - - return $this; - } - - /** - * Use the Order relation Order object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderQuery A secondary query class using the current class as primary query - */ - public function useOrderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinOrder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Order', '\Thelia\Model\OrderQuery'); - } - - /** - * Filter the query by a related OrderStatusI18n object - * - * @param OrderStatusI18n|PropelObjectCollection $orderStatusI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return OrderStatusQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByOrderStatusI18n($orderStatusI18n, $comparison = null) - { - if ($orderStatusI18n instanceof OrderStatusI18n) { - return $this - ->addUsingAlias(OrderStatusPeer::ID, $orderStatusI18n->getId(), $comparison); - } elseif ($orderStatusI18n instanceof PropelObjectCollection) { - return $this - ->useOrderStatusI18nQuery() - ->filterByPrimaryKeys($orderStatusI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByOrderStatusI18n() only accepts arguments of type OrderStatusI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the OrderStatusI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function joinOrderStatusI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('OrderStatusI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'OrderStatusI18n'); - } - - return $this; - } - - /** - * Use the OrderStatusI18n relation OrderStatusI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\OrderStatusI18nQuery A secondary query class using the current class as primary query - */ - public function useOrderStatusI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinOrderStatusI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', '\Thelia\Model\OrderStatusI18nQuery'); - } - - /** - * Exclude object from result - * - * @param OrderStatus $orderStatus Object to remove from the list of results - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function prune($orderStatus = null) - { - if ($orderStatus) { - $this->addUsingAlias(OrderStatusPeer::ID, $orderStatus->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(OrderStatusPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(OrderStatusPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(OrderStatusPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(OrderStatusPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(OrderStatusPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(OrderStatusPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; - - return $this - ->joinOrderStatusI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return OrderStatusQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('OrderStatusI18n'); - $this->with['OrderStatusI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return OrderStatusI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'OrderStatusI18n', 'Thelia\Model\OrderStatusI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseProduct.php b/core/lib/Thelia/Model/om/BaseProduct.php deleted file mode 100755 index a48b71c31..000000000 --- a/core/lib/Thelia/Model/om/BaseProduct.php +++ /dev/null @@ -1,6634 +0,0 @@ -newness = 0; - $this->promo = 0; - $this->quantity = 0; - $this->visible = 0; - $this->version = 0; - } - - /** - * Initializes internal state of BaseProduct object. - * @see applyDefaults() - */ - public function __construct() - { - parent::__construct(); - $this->applyDefaultValues(); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the [tax_rule_id] column value. - * - * @return int - */ - public function getTaxRuleId() - { - return $this->tax_rule_id; - } - - /** - * Get the [ref] column value. - * - * @return string - */ - public function getRef() - { - return $this->ref; - } - - /** - * Get the [price] column value. - * - * @return double - */ - public function getPrice() - { - return $this->price; - } - - /** - * Get the [price2] column value. - * - * @return double - */ - public function getPrice2() - { - return $this->price2; - } - - /** - * Get the [ecotax] column value. - * - * @return double - */ - public function getEcotax() - { - return $this->ecotax; - } - - /** - * Get the [newness] column value. - * - * @return int - */ - public function getNewness() - { - return $this->newness; - } - - /** - * Get the [promo] column value. - * - * @return int - */ - public function getPromo() - { - return $this->promo; - } - - /** - * Get the [quantity] column value. - * - * @return int - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * Get the [visible] column value. - * - * @return int - */ - public function getVisible() - { - return $this->visible; - } - - /** - * Get the [weight] column value. - * - * @return double - */ - public function getWeight() - { - return $this->weight; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 Product The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ProductPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [tax_rule_id] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setTaxRuleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->tax_rule_id !== $v) { - $this->tax_rule_id = $v; - $this->modifiedColumns[] = ProductPeer::TAX_RULE_ID; - } - - if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) { - $this->aTaxRule = null; - } - - - return $this; - } // setTaxRuleId() - - /** - * Set the value of [ref] column. - * - * @param string $v new value - * @return Product The current object (for fluent API support) - */ - public function setRef($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->ref !== $v) { - $this->ref = $v; - $this->modifiedColumns[] = ProductPeer::REF; - } - - - return $this; - } // setRef() - - /** - * Set the value of [price] column. - * - * @param double $v new value - * @return Product The current object (for fluent API support) - */ - public function setPrice($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->price !== $v) { - $this->price = $v; - $this->modifiedColumns[] = ProductPeer::PRICE; - } - - - return $this; - } // setPrice() - - /** - * Set the value of [price2] column. - * - * @param double $v new value - * @return Product The current object (for fluent API support) - */ - public function setPrice2($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->price2 !== $v) { - $this->price2 = $v; - $this->modifiedColumns[] = ProductPeer::PRICE2; - } - - - return $this; - } // setPrice2() - - /** - * Set the value of [ecotax] column. - * - * @param double $v new value - * @return Product The current object (for fluent API support) - */ - public function setEcotax($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->ecotax !== $v) { - $this->ecotax = $v; - $this->modifiedColumns[] = ProductPeer::ECOTAX; - } - - - return $this; - } // setEcotax() - - /** - * Set the value of [newness] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setNewness($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->newness !== $v) { - $this->newness = $v; - $this->modifiedColumns[] = ProductPeer::NEWNESS; - } - - - return $this; - } // setNewness() - - /** - * Set the value of [promo] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setPromo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->promo !== $v) { - $this->promo = $v; - $this->modifiedColumns[] = ProductPeer::PROMO; - } - - - return $this; - } // setPromo() - - /** - * Set the value of [quantity] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setQuantity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->quantity !== $v) { - $this->quantity = $v; - $this->modifiedColumns[] = ProductPeer::QUANTITY; - } - - - return $this; - } // setQuantity() - - /** - * Set the value of [visible] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setVisible($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->visible !== $v) { - $this->visible = $v; - $this->modifiedColumns[] = ProductPeer::VISIBLE; - } - - - return $this; - } // setVisible() - - /** - * Set the value of [weight] column. - * - * @param double $v new value - * @return Product The current object (for fluent API support) - */ - public function setWeight($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->weight !== $v) { - $this->weight = $v; - $this->modifiedColumns[] = ProductPeer::WEIGHT; - } - - - return $this; - } // setWeight() - - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return Product The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = ProductPeer::POSITION; - } - - - return $this; - } // setPosition() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Product The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ProductPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Product The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ProductPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->newness !== 0) { - return false; - } - - if ($this->promo !== 0) { - return false; - } - - if ($this->quantity !== 0) { - return false; - } - - if ($this->visible !== 0) { - return false; - } - - 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->quantity = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; - $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; - $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null; - $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; - $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 17; // 17 = ProductPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Product object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) { - $this->aTaxRule = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ProductPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aTaxRule = null; - $this->collProductCategorys = null; - - $this->collFeatureProds = null; - - $this->collStocks = null; - - $this->collContentAssocs = null; - - $this->collImages = null; - - $this->collDocuments = null; - - $this->collAccessorysRelatedByProductId = null; - - $this->collAccessorysRelatedByAccessory = null; - - $this->collRewritings = null; - - $this->collProductI18ns = null; - - $this->collProductVersions = null; - - $this->collCategorys = null; - $this->collProductsRelatedByAccessory = null; - $this->collProductsRelatedByProductId = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ProductQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - // 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 - if (!$this->isColumnModified(ProductPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ProductPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ProductPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - // versionable behavior - if (isset($createVersion)) { - $this->addVersion($con); - } - ProductPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTaxRule !== null) { - if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) { - $affectedRows += $this->aTaxRule->save($con); - } - $this->setTaxRule($this->aTaxRule); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->categorysScheduledForDeletion !== null) { - if (!$this->categorysScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->categorysScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - ProductCategoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->categorysScheduledForDeletion = null; - } - - foreach ($this->getCategorys() as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } elseif ($this->collCategorys) { - foreach ($this->collCategorys as $category) { - if ($category->isModified()) { - $category->save($con); - } - } - } - - if ($this->productsRelatedByAccessoryScheduledForDeletion !== null) { - if (!$this->productsRelatedByAccessoryScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->productsRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - AccessoryRelatedByProductIdQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->productsRelatedByAccessoryScheduledForDeletion = null; - } - - foreach ($this->getProductsRelatedByAccessory() as $productRelatedByAccessory) { - if ($productRelatedByAccessory->isModified()) { - $productRelatedByAccessory->save($con); - } - } - } elseif ($this->collProductsRelatedByAccessory) { - foreach ($this->collProductsRelatedByAccessory as $productRelatedByAccessory) { - if ($productRelatedByAccessory->isModified()) { - $productRelatedByAccessory->save($con); - } - } - } - - if ($this->productsRelatedByProductIdScheduledForDeletion !== null) { - if (!$this->productsRelatedByProductIdScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->productsRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - AccessoryRelatedByAccessoryQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->productsRelatedByProductIdScheduledForDeletion = null; - } - - foreach ($this->getProductsRelatedByProductId() as $productRelatedByProductId) { - if ($productRelatedByProductId->isModified()) { - $productRelatedByProductId->save($con); - } - } - } elseif ($this->collProductsRelatedByProductId) { - foreach ($this->collProductsRelatedByProductId as $productRelatedByProductId) { - if ($productRelatedByProductId->isModified()) { - $productRelatedByProductId->save($con); - } - } - } - - if ($this->productCategorysScheduledForDeletion !== null) { - if (!$this->productCategorysScheduledForDeletion->isEmpty()) { - ProductCategoryQuery::create() - ->filterByPrimaryKeys($this->productCategorysScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productCategorysScheduledForDeletion = null; - } - } - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->featureProdsScheduledForDeletion !== null) { - if (!$this->featureProdsScheduledForDeletion->isEmpty()) { - FeatureProdQuery::create() - ->filterByPrimaryKeys($this->featureProdsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->featureProdsScheduledForDeletion = null; - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->stocksScheduledForDeletion !== null) { - if (!$this->stocksScheduledForDeletion->isEmpty()) { - StockQuery::create() - ->filterByPrimaryKeys($this->stocksScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->stocksScheduledForDeletion = null; - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->contentAssocsScheduledForDeletion !== null) { - if (!$this->contentAssocsScheduledForDeletion->isEmpty()) { - foreach ($this->contentAssocsScheduledForDeletion as $contentAssoc) { - // need to save related object because we set the relation to null - $contentAssoc->save($con); - } - $this->contentAssocsScheduledForDeletion = null; - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->imagesScheduledForDeletion !== null) { - if (!$this->imagesScheduledForDeletion->isEmpty()) { - foreach ($this->imagesScheduledForDeletion as $image) { - // need to save related object because we set the relation to null - $image->save($con); - } - $this->imagesScheduledForDeletion = null; - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->documentsScheduledForDeletion !== null) { - if (!$this->documentsScheduledForDeletion->isEmpty()) { - foreach ($this->documentsScheduledForDeletion as $document) { - // need to save related object because we set the relation to null - $document->save($con); - } - $this->documentsScheduledForDeletion = null; - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->accessorysRelatedByProductIdScheduledForDeletion !== null) { - if (!$this->accessorysRelatedByProductIdScheduledForDeletion->isEmpty()) { - AccessoryQuery::create() - ->filterByPrimaryKeys($this->accessorysRelatedByProductIdScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->accessorysRelatedByProductIdScheduledForDeletion = null; - } - } - - if ($this->collAccessorysRelatedByProductId !== null) { - foreach ($this->collAccessorysRelatedByProductId as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->accessorysRelatedByAccessoryScheduledForDeletion !== null) { - if (!$this->accessorysRelatedByAccessoryScheduledForDeletion->isEmpty()) { - AccessoryQuery::create() - ->filterByPrimaryKeys($this->accessorysRelatedByAccessoryScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->accessorysRelatedByAccessoryScheduledForDeletion = null; - } - } - - if ($this->collAccessorysRelatedByAccessory !== null) { - foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->rewritingsScheduledForDeletion !== null) { - if (!$this->rewritingsScheduledForDeletion->isEmpty()) { - foreach ($this->rewritingsScheduledForDeletion as $rewriting) { - // need to save related object because we set the relation to null - $rewriting->save($con); - } - $this->rewritingsScheduledForDeletion = null; - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->productI18nsScheduledForDeletion !== null) { - if (!$this->productI18nsScheduledForDeletion->isEmpty()) { - ProductI18nQuery::create() - ->filterByPrimaryKeys($this->productI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->productI18nsScheduledForDeletion = null; - } - } - - if ($this->collProductI18ns !== null) { - foreach ($this->collProductI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - 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() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ProductPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProductPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ProductPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; - } - if ($this->isColumnModified(ProductPeer::REF)) { - $modifiedColumns[':p' . $index++] = '`ref`'; - } - if ($this->isColumnModified(ProductPeer::PRICE)) { - $modifiedColumns[':p' . $index++] = '`price`'; - } - if ($this->isColumnModified(ProductPeer::PRICE2)) { - $modifiedColumns[':p' . $index++] = '`price2`'; - } - if ($this->isColumnModified(ProductPeer::ECOTAX)) { - $modifiedColumns[':p' . $index++] = '`ecotax`'; - } - if ($this->isColumnModified(ProductPeer::NEWNESS)) { - $modifiedColumns[':p' . $index++] = '`newness`'; - } - if ($this->isColumnModified(ProductPeer::PROMO)) { - $modifiedColumns[':p' . $index++] = '`promo`'; - } - if ($this->isColumnModified(ProductPeer::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; - } - if ($this->isColumnModified(ProductPeer::VISIBLE)) { - $modifiedColumns[':p' . $index++] = '`visible`'; - } - if ($this->isColumnModified(ProductPeer::WEIGHT)) { - $modifiedColumns[':p' . $index++] = '`weight`'; - } - if ($this->isColumnModified(ProductPeer::POSITION)) { - $modifiedColumns[':p' . $index++] = '`position`'; - } - if ($this->isColumnModified(ProductPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ProductPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - 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)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`tax_rule_id`': - $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); - break; - case '`ref`': - $stmt->bindValue($identifier, $this->ref, PDO::PARAM_STR); - break; - case '`price`': - $stmt->bindValue($identifier, $this->price, PDO::PARAM_STR); - break; - case '`price2`': - $stmt->bindValue($identifier, $this->price2, PDO::PARAM_STR); - break; - case '`ecotax`': - $stmt->bindValue($identifier, $this->ecotax, PDO::PARAM_STR); - break; - case '`newness`': - $stmt->bindValue($identifier, $this->newness, PDO::PARAM_INT); - break; - case '`promo`': - $stmt->bindValue($identifier, $this->promo, PDO::PARAM_INT); - break; - case '`quantity`': - $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT); - break; - case '`visible`': - $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); - break; - case '`weight`': - $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - 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); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTaxRule !== null) { - if (!$this->aTaxRule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures()); - } - } - - - if (($retval = ProductPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collProductCategorys !== null) { - foreach ($this->collProductCategorys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collFeatureProds !== null) { - foreach ($this->collFeatureProds as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collStocks !== null) { - foreach ($this->collStocks as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collContentAssocs !== null) { - foreach ($this->collContentAssocs as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collImages !== null) { - foreach ($this->collImages as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collDocuments !== null) { - foreach ($this->collDocuments as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAccessorysRelatedByProductId !== null) { - foreach ($this->collAccessorysRelatedByProductId as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collAccessorysRelatedByAccessory !== null) { - foreach ($this->collAccessorysRelatedByAccessory as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collRewritings !== null) { - foreach ($this->collRewritings as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collProductI18ns !== null) { - foreach ($this->collProductI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collProductVersions !== null) { - foreach ($this->collProductVersions as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getTaxRuleId(); - break; - case 2: - return $this->getRef(); - break; - case 3: - return $this->getPrice(); - break; - case 4: - return $this->getPrice2(); - break; - case 5: - return $this->getEcotax(); - break; - case 6: - return $this->getNewness(); - break; - case 7: - return $this->getPromo(); - break; - case 8: - return $this->getQuantity(); - break; - case 9: - return $this->getVisible(); - break; - case 10: - return $this->getWeight(); - break; - case 11: - return $this->getPosition(); - break; - case 12: - return $this->getCreatedAt(); - break; - case 13: - return $this->getUpdatedAt(); - break; - 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['Product'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Product'][$this->getPrimaryKey()] = true; - $keys = ProductPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getTaxRuleId(), - $keys[2] => $this->getRef(), - $keys[3] => $this->getPrice(), - $keys[4] => $this->getPrice2(), - $keys[5] => $this->getEcotax(), - $keys[6] => $this->getNewness(), - $keys[7] => $this->getPromo(), - $keys[8] => $this->getQuantity(), - $keys[9] => $this->getVisible(), - $keys[10] => $this->getWeight(), - $keys[11] => $this->getPosition(), - $keys[12] => $this->getCreatedAt(), - $keys[13] => $this->getUpdatedAt(), - $keys[14] => $this->getVersion(), - $keys[15] => $this->getVersionCreatedAt(), - $keys[16] => $this->getVersionCreatedBy(), - ); - if ($includeForeignObjects) { - if (null !== $this->aTaxRule) { - $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->collProductCategorys) { - $result['ProductCategorys'] = $this->collProductCategorys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collFeatureProds) { - $result['FeatureProds'] = $this->collFeatureProds->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collStocks) { - $result['Stocks'] = $this->collStocks->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collContentAssocs) { - $result['ContentAssocs'] = $this->collContentAssocs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collImages) { - $result['Images'] = $this->collImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collDocuments) { - $result['Documents'] = $this->collDocuments->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAccessorysRelatedByProductId) { - $result['AccessorysRelatedByProductId'] = $this->collAccessorysRelatedByProductId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collAccessorysRelatedByAccessory) { - $result['AccessorysRelatedByAccessory'] = $this->collAccessorysRelatedByAccessory->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collRewritings) { - $result['Rewritings'] = $this->collRewritings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - 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; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ProductPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setTaxRuleId($value); - break; - case 2: - $this->setRef($value); - break; - case 3: - $this->setPrice($value); - break; - case 4: - $this->setPrice2($value); - break; - case 5: - $this->setEcotax($value); - break; - case 6: - $this->setNewness($value); - break; - case 7: - $this->setPromo($value); - break; - case 8: - $this->setQuantity($value); - break; - case 9: - $this->setVisible($value); - break; - case 10: - $this->setWeight($value); - break; - case 11: - $this->setPosition($value); - break; - case 12: - $this->setCreatedAt($value); - break; - case 13: - $this->setUpdatedAt($value); - break; - 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 = ProductPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setRef($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setPrice($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setPrice2($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setEcotax($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setNewness($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setPromo($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setQuantity($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); - 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(ProductPeer::DATABASE_NAME); - - if ($this->isColumnModified(ProductPeer::ID)) $criteria->add(ProductPeer::ID, $this->id); - if ($this->isColumnModified(ProductPeer::TAX_RULE_ID)) $criteria->add(ProductPeer::TAX_RULE_ID, $this->tax_rule_id); - if ($this->isColumnModified(ProductPeer::REF)) $criteria->add(ProductPeer::REF, $this->ref); - if ($this->isColumnModified(ProductPeer::PRICE)) $criteria->add(ProductPeer::PRICE, $this->price); - if ($this->isColumnModified(ProductPeer::PRICE2)) $criteria->add(ProductPeer::PRICE2, $this->price2); - if ($this->isColumnModified(ProductPeer::ECOTAX)) $criteria->add(ProductPeer::ECOTAX, $this->ecotax); - if ($this->isColumnModified(ProductPeer::NEWNESS)) $criteria->add(ProductPeer::NEWNESS, $this->newness); - if ($this->isColumnModified(ProductPeer::PROMO)) $criteria->add(ProductPeer::PROMO, $this->promo); - if ($this->isColumnModified(ProductPeer::QUANTITY)) $criteria->add(ProductPeer::QUANTITY, $this->quantity); - if ($this->isColumnModified(ProductPeer::VISIBLE)) $criteria->add(ProductPeer::VISIBLE, $this->visible); - if ($this->isColumnModified(ProductPeer::WEIGHT)) $criteria->add(ProductPeer::WEIGHT, $this->weight); - if ($this->isColumnModified(ProductPeer::POSITION)) $criteria->add(ProductPeer::POSITION, $this->position); - if ($this->isColumnModified(ProductPeer::CREATED_AT)) $criteria->add(ProductPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ProductPeer::UPDATED_AT)) $criteria->add(ProductPeer::UPDATED_AT, $this->updated_at); - 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; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ProductPeer::DATABASE_NAME); - $criteria->add(ProductPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Product (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setTaxRuleId($this->getTaxRuleId()); - $copyObj->setRef($this->getRef()); - $copyObj->setPrice($this->getPrice()); - $copyObj->setPrice2($this->getPrice2()); - $copyObj->setEcotax($this->getEcotax()); - $copyObj->setNewness($this->getNewness()); - $copyObj->setPromo($this->getPromo()); - $copyObj->setQuantity($this->getQuantity()); - $copyObj->setVisible($this->getVisible()); - $copyObj->setWeight($this->getWeight()); - $copyObj->setPosition($this->getPosition()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - $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; - - foreach ($this->getProductCategorys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductCategory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getFeatureProds() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addFeatureProd($relObj->copy($deepCopy)); - } - } - - foreach ($this->getStocks() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addStock($relObj->copy($deepCopy)); - } - } - - foreach ($this->getContentAssocs() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addContentAssoc($relObj->copy($deepCopy)); - } - } - - foreach ($this->getImages() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addImage($relObj->copy($deepCopy)); - } - } - - foreach ($this->getDocuments() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addDocument($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAccessorysRelatedByProductId() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAccessoryRelatedByProductId($relObj->copy($deepCopy)); - } - } - - foreach ($this->getAccessorysRelatedByAccessory() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAccessoryRelatedByAccessory($relObj->copy($deepCopy)); - } - } - - foreach ($this->getRewritings() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addRewriting($relObj->copy($deepCopy)); - } - } - - foreach ($this->getProductI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProductI18n($relObj->copy($deepCopy)); - } - } - - 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) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Product Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ProductPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ProductPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a TaxRule object. - * - * @param TaxRule $v - * @return Product The current object (for fluent API support) - * @throws PropelException - */ - public function setTaxRule(TaxRule $v = null) - { - if ($v === null) { - $this->setTaxRuleId(NULL); - } else { - $this->setTaxRuleId($v->getId()); - } - - $this->aTaxRule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the TaxRule object, it will not be re-added. - if ($v !== null) { - $v->addProduct($this); - } - - - return $this; - } - - - /** - * Get the associated TaxRule object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return TaxRule The associated TaxRule object. - * @throws PropelException - */ - public function getTaxRule(PropelPDO $con = null, $doQuery = true) - { - if ($this->aTaxRule === null && ($this->tax_rule_id !== null) && $doQuery) { - $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aTaxRule->addProducts($this); - */ - } - - return $this->aTaxRule; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('ProductCategory' == $relationName) { - $this->initProductCategorys(); - } - if ('FeatureProd' == $relationName) { - $this->initFeatureProds(); - } - if ('Stock' == $relationName) { - $this->initStocks(); - } - if ('ContentAssoc' == $relationName) { - $this->initContentAssocs(); - } - if ('Image' == $relationName) { - $this->initImages(); - } - if ('Document' == $relationName) { - $this->initDocuments(); - } - if ('AccessoryRelatedByProductId' == $relationName) { - $this->initAccessorysRelatedByProductId(); - } - if ('AccessoryRelatedByAccessory' == $relationName) { - $this->initAccessorysRelatedByAccessory(); - } - if ('Rewriting' == $relationName) { - $this->initRewritings(); - } - if ('ProductI18n' == $relationName) { - $this->initProductI18ns(); - } - if ('ProductVersion' == $relationName) { - $this->initProductVersions(); - } - } - - /** - * Clears out the collProductCategorys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addProductCategorys() - */ - public function clearProductCategorys() - { - $this->collProductCategorys = null; // important to set this to null since that means it is uninitialized - $this->collProductCategorysPartial = null; - - return $this; - } - - /** - * reset is the collProductCategorys collection loaded partially - * - * @return void - */ - public function resetPartialProductCategorys($v = true) - { - $this->collProductCategorysPartial = $v; - } - - /** - * Initializes the collProductCategorys collection. - * - * By default this just sets the collProductCategorys collection to an empty array (like clearcollProductCategorys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initProductCategorys($overrideExisting = true) - { - if (null !== $this->collProductCategorys && !$overrideExisting) { - return; - } - $this->collProductCategorys = new PropelObjectCollection(); - $this->collProductCategorys->setModel('ProductCategory'); - } - - /** - * Gets an array of ProductCategory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - * @throws PropelException - */ - public function getProductCategorys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { - // return empty collection - $this->initProductCategorys(); - } else { - $collProductCategorys = ProductCategoryQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductCategorysPartial && count($collProductCategorys)) { - $this->initProductCategorys(false); - - foreach($collProductCategorys as $obj) { - if (false == $this->collProductCategorys->contains($obj)) { - $this->collProductCategorys->append($obj); - } - } - - $this->collProductCategorysPartial = true; - } - - $collProductCategorys->getInternalIterator()->rewind(); - return $collProductCategorys; - } - - if($partial && $this->collProductCategorys) { - foreach($this->collProductCategorys as $obj) { - if($obj->isNew()) { - $collProductCategorys[] = $obj; - } - } - } - - $this->collProductCategorys = $collProductCategorys; - $this->collProductCategorysPartial = false; - } - } - - return $this->collProductCategorys; - } - - /** - * Sets a collection of ProductCategory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $productCategorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setProductCategorys(PropelCollection $productCategorys, PropelPDO $con = null) - { - $productCategorysToDelete = $this->getProductCategorys(new Criteria(), $con)->diff($productCategorys); - - $this->productCategorysScheduledForDeletion = unserialize(serialize($productCategorysToDelete)); - - foreach ($productCategorysToDelete as $productCategoryRemoved) { - $productCategoryRemoved->setProduct(null); - } - - $this->collProductCategorys = null; - foreach ($productCategorys as $productCategory) { - $this->addProductCategory($productCategory); - } - - $this->collProductCategorys = $productCategorys; - $this->collProductCategorysPartial = false; - - return $this; - } - - /** - * Returns the number of related ProductCategory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ProductCategory objects. - * @throws PropelException - */ - public function countProductCategorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductCategorysPartial && !$this->isNew(); - if (null === $this->collProductCategorys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductCategorys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getProductCategorys()); - } - $query = ProductCategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collProductCategorys); - } - - /** - * Method called to associate a ProductCategory object to this object - * through the ProductCategory foreign key attribute. - * - * @param ProductCategory $l ProductCategory - * @return Product The current object (for fluent API support) - */ - public function addProductCategory(ProductCategory $l) - { - if ($this->collProductCategorys === null) { - $this->initProductCategorys(); - $this->collProductCategorysPartial = true; - } - if (!in_array($l, $this->collProductCategorys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddProductCategory($l); - } - - return $this; - } - - /** - * @param ProductCategory $productCategory The productCategory object to add. - */ - protected function doAddProductCategory($productCategory) - { - $this->collProductCategorys[]= $productCategory; - $productCategory->setProduct($this); - } - - /** - * @param ProductCategory $productCategory The productCategory object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeProductCategory($productCategory) - { - if ($this->getProductCategorys()->contains($productCategory)) { - $this->collProductCategorys->remove($this->collProductCategorys->search($productCategory)); - if (null === $this->productCategorysScheduledForDeletion) { - $this->productCategorysScheduledForDeletion = clone $this->collProductCategorys; - $this->productCategorysScheduledForDeletion->clear(); - } - $this->productCategorysScheduledForDeletion[]= clone $productCategory; - $productCategory->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ProductCategorys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ProductCategory[] List of ProductCategory objects - */ - public function getProductCategorysJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ProductCategoryQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getProductCategorys($query, $con); - } - - /** - * Clears out the collFeatureProds collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addFeatureProds() - */ - public function clearFeatureProds() - { - $this->collFeatureProds = null; // important to set this to null since that means it is uninitialized - $this->collFeatureProdsPartial = null; - - return $this; - } - - /** - * reset is the collFeatureProds collection loaded partially - * - * @return void - */ - public function resetPartialFeatureProds($v = true) - { - $this->collFeatureProdsPartial = $v; - } - - /** - * Initializes the collFeatureProds collection. - * - * By default this just sets the collFeatureProds collection to an empty array (like clearcollFeatureProds()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initFeatureProds($overrideExisting = true) - { - if (null !== $this->collFeatureProds && !$overrideExisting) { - return; - } - $this->collFeatureProds = new PropelObjectCollection(); - $this->collFeatureProds->setModel('FeatureProd'); - } - - /** - * Gets an array of FeatureProd objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - * @throws PropelException - */ - public function getFeatureProds($criteria = null, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - // return empty collection - $this->initFeatureProds(); - } else { - $collFeatureProds = FeatureProdQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collFeatureProdsPartial && count($collFeatureProds)) { - $this->initFeatureProds(false); - - foreach($collFeatureProds as $obj) { - if (false == $this->collFeatureProds->contains($obj)) { - $this->collFeatureProds->append($obj); - } - } - - $this->collFeatureProdsPartial = true; - } - - $collFeatureProds->getInternalIterator()->rewind(); - return $collFeatureProds; - } - - if($partial && $this->collFeatureProds) { - foreach($this->collFeatureProds as $obj) { - if($obj->isNew()) { - $collFeatureProds[] = $obj; - } - } - } - - $this->collFeatureProds = $collFeatureProds; - $this->collFeatureProdsPartial = false; - } - } - - return $this->collFeatureProds; - } - - /** - * Sets a collection of FeatureProd objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $featureProds A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setFeatureProds(PropelCollection $featureProds, PropelPDO $con = null) - { - $featureProdsToDelete = $this->getFeatureProds(new Criteria(), $con)->diff($featureProds); - - $this->featureProdsScheduledForDeletion = unserialize(serialize($featureProdsToDelete)); - - foreach ($featureProdsToDelete as $featureProdRemoved) { - $featureProdRemoved->setProduct(null); - } - - $this->collFeatureProds = null; - foreach ($featureProds as $featureProd) { - $this->addFeatureProd($featureProd); - } - - $this->collFeatureProds = $featureProds; - $this->collFeatureProdsPartial = false; - - return $this; - } - - /** - * Returns the number of related FeatureProd objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related FeatureProd objects. - * @throws PropelException - */ - public function countFeatureProds(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collFeatureProdsPartial && !$this->isNew(); - if (null === $this->collFeatureProds || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collFeatureProds) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getFeatureProds()); - } - $query = FeatureProdQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collFeatureProds); - } - - /** - * Method called to associate a FeatureProd object to this object - * through the FeatureProd foreign key attribute. - * - * @param FeatureProd $l FeatureProd - * @return Product The current object (for fluent API support) - */ - public function addFeatureProd(FeatureProd $l) - { - if ($this->collFeatureProds === null) { - $this->initFeatureProds(); - $this->collFeatureProdsPartial = true; - } - if (!in_array($l, $this->collFeatureProds->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddFeatureProd($l); - } - - return $this; - } - - /** - * @param FeatureProd $featureProd The featureProd object to add. - */ - protected function doAddFeatureProd($featureProd) - { - $this->collFeatureProds[]= $featureProd; - $featureProd->setProduct($this); - } - - /** - * @param FeatureProd $featureProd The featureProd object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeFeatureProd($featureProd) - { - if ($this->getFeatureProds()->contains($featureProd)) { - $this->collFeatureProds->remove($this->collFeatureProds->search($featureProd)); - if (null === $this->featureProdsScheduledForDeletion) { - $this->featureProdsScheduledForDeletion = clone $this->collFeatureProds; - $this->featureProdsScheduledForDeletion->clear(); - } - $this->featureProdsScheduledForDeletion[]= clone $featureProd; - $featureProd->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('Feature', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related FeatureProds from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|FeatureProd[] List of FeatureProd objects - */ - public function getFeatureProdsJoinFeatureAv($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = FeatureProdQuery::create(null, $criteria); - $query->joinWith('FeatureAv', $join_behavior); - - return $this->getFeatureProds($query, $con); - } - - /** - * Clears out the collStocks collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addStocks() - */ - public function clearStocks() - { - $this->collStocks = null; // important to set this to null since that means it is uninitialized - $this->collStocksPartial = null; - - return $this; - } - - /** - * reset is the collStocks collection loaded partially - * - * @return void - */ - public function resetPartialStocks($v = true) - { - $this->collStocksPartial = $v; - } - - /** - * Initializes the collStocks collection. - * - * By default this just sets the collStocks collection to an empty array (like clearcollStocks()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initStocks($overrideExisting = true) - { - if (null !== $this->collStocks && !$overrideExisting) { - return; - } - $this->collStocks = new PropelObjectCollection(); - $this->collStocks->setModel('Stock'); - } - - /** - * Gets an array of Stock objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Stock[] List of Stock objects - * @throws PropelException - */ - public function getStocks($criteria = null, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - // return empty collection - $this->initStocks(); - } else { - $collStocks = StockQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collStocksPartial && count($collStocks)) { - $this->initStocks(false); - - foreach($collStocks as $obj) { - if (false == $this->collStocks->contains($obj)) { - $this->collStocks->append($obj); - } - } - - $this->collStocksPartial = true; - } - - $collStocks->getInternalIterator()->rewind(); - return $collStocks; - } - - if($partial && $this->collStocks) { - foreach($this->collStocks as $obj) { - if($obj->isNew()) { - $collStocks[] = $obj; - } - } - } - - $this->collStocks = $collStocks; - $this->collStocksPartial = false; - } - } - - return $this->collStocks; - } - - /** - * Sets a collection of Stock objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $stocks A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setStocks(PropelCollection $stocks, PropelPDO $con = null) - { - $stocksToDelete = $this->getStocks(new Criteria(), $con)->diff($stocks); - - $this->stocksScheduledForDeletion = unserialize(serialize($stocksToDelete)); - - foreach ($stocksToDelete as $stockRemoved) { - $stockRemoved->setProduct(null); - } - - $this->collStocks = null; - foreach ($stocks as $stock) { - $this->addStock($stock); - } - - $this->collStocks = $stocks; - $this->collStocksPartial = false; - - return $this; - } - - /** - * Returns the number of related Stock objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Stock objects. - * @throws PropelException - */ - public function countStocks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collStocksPartial && !$this->isNew(); - if (null === $this->collStocks || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collStocks) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getStocks()); - } - $query = StockQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collStocks); - } - - /** - * Method called to associate a Stock object to this object - * through the Stock foreign key attribute. - * - * @param Stock $l Stock - * @return Product The current object (for fluent API support) - */ - public function addStock(Stock $l) - { - if ($this->collStocks === null) { - $this->initStocks(); - $this->collStocksPartial = true; - } - if (!in_array($l, $this->collStocks->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddStock($l); - } - - return $this; - } - - /** - * @param Stock $stock The stock object to add. - */ - protected function doAddStock($stock) - { - $this->collStocks[]= $stock; - $stock->setProduct($this); - } - - /** - * @param Stock $stock The stock object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeStock($stock) - { - if ($this->getStocks()->contains($stock)) { - $this->collStocks->remove($this->collStocks->search($stock)); - if (null === $this->stocksScheduledForDeletion) { - $this->stocksScheduledForDeletion = clone $this->collStocks; - $this->stocksScheduledForDeletion->clear(); - } - $this->stocksScheduledForDeletion[]= clone $stock; - $stock->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Stocks from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Stock[] List of Stock objects - */ - public function getStocksJoinCombination($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = StockQuery::create(null, $criteria); - $query->joinWith('Combination', $join_behavior); - - return $this->getStocks($query, $con); - } - - /** - * Clears out the collContentAssocs collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addContentAssocs() - */ - public function clearContentAssocs() - { - $this->collContentAssocs = null; // important to set this to null since that means it is uninitialized - $this->collContentAssocsPartial = null; - - return $this; - } - - /** - * reset is the collContentAssocs collection loaded partially - * - * @return void - */ - public function resetPartialContentAssocs($v = true) - { - $this->collContentAssocsPartial = $v; - } - - /** - * Initializes the collContentAssocs collection. - * - * By default this just sets the collContentAssocs collection to an empty array (like clearcollContentAssocs()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initContentAssocs($overrideExisting = true) - { - if (null !== $this->collContentAssocs && !$overrideExisting) { - return; - } - $this->collContentAssocs = new PropelObjectCollection(); - $this->collContentAssocs->setModel('ContentAssoc'); - } - - /** - * Gets an array of ContentAssoc objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - * @throws PropelException - */ - public function getContentAssocs($criteria = null, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - // return empty collection - $this->initContentAssocs(); - } else { - $collContentAssocs = ContentAssocQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collContentAssocsPartial && count($collContentAssocs)) { - $this->initContentAssocs(false); - - foreach($collContentAssocs as $obj) { - if (false == $this->collContentAssocs->contains($obj)) { - $this->collContentAssocs->append($obj); - } - } - - $this->collContentAssocsPartial = true; - } - - $collContentAssocs->getInternalIterator()->rewind(); - return $collContentAssocs; - } - - if($partial && $this->collContentAssocs) { - foreach($this->collContentAssocs as $obj) { - if($obj->isNew()) { - $collContentAssocs[] = $obj; - } - } - } - - $this->collContentAssocs = $collContentAssocs; - $this->collContentAssocsPartial = false; - } - } - - return $this->collContentAssocs; - } - - /** - * Sets a collection of ContentAssoc objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $contentAssocs A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setContentAssocs(PropelCollection $contentAssocs, PropelPDO $con = null) - { - $contentAssocsToDelete = $this->getContentAssocs(new Criteria(), $con)->diff($contentAssocs); - - $this->contentAssocsScheduledForDeletion = unserialize(serialize($contentAssocsToDelete)); - - foreach ($contentAssocsToDelete as $contentAssocRemoved) { - $contentAssocRemoved->setProduct(null); - } - - $this->collContentAssocs = null; - foreach ($contentAssocs as $contentAssoc) { - $this->addContentAssoc($contentAssoc); - } - - $this->collContentAssocs = $contentAssocs; - $this->collContentAssocsPartial = false; - - return $this; - } - - /** - * Returns the number of related ContentAssoc objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ContentAssoc objects. - * @throws PropelException - */ - public function countContentAssocs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collContentAssocsPartial && !$this->isNew(); - if (null === $this->collContentAssocs || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collContentAssocs) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getContentAssocs()); - } - $query = ContentAssocQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collContentAssocs); - } - - /** - * Method called to associate a ContentAssoc object to this object - * through the ContentAssoc foreign key attribute. - * - * @param ContentAssoc $l ContentAssoc - * @return Product The current object (for fluent API support) - */ - public function addContentAssoc(ContentAssoc $l) - { - if ($this->collContentAssocs === null) { - $this->initContentAssocs(); - $this->collContentAssocsPartial = true; - } - if (!in_array($l, $this->collContentAssocs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddContentAssoc($l); - } - - return $this; - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to add. - */ - protected function doAddContentAssoc($contentAssoc) - { - $this->collContentAssocs[]= $contentAssoc; - $contentAssoc->setProduct($this); - } - - /** - * @param ContentAssoc $contentAssoc The contentAssoc object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeContentAssoc($contentAssoc) - { - if ($this->getContentAssocs()->contains($contentAssoc)) { - $this->collContentAssocs->remove($this->collContentAssocs->search($contentAssoc)); - if (null === $this->contentAssocsScheduledForDeletion) { - $this->contentAssocsScheduledForDeletion = clone $this->collContentAssocs; - $this->contentAssocsScheduledForDeletion->clear(); - } - $this->contentAssocsScheduledForDeletion[]= $contentAssoc; - $contentAssoc->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related ContentAssocs from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|ContentAssoc[] List of ContentAssoc objects - */ - public function getContentAssocsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ContentAssocQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getContentAssocs($query, $con); - } - - /** - * Clears out the collImages collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addImages() - */ - public function clearImages() - { - $this->collImages = null; // important to set this to null since that means it is uninitialized - $this->collImagesPartial = null; - - return $this; - } - - /** - * reset is the collImages collection loaded partially - * - * @return void - */ - public function resetPartialImages($v = true) - { - $this->collImagesPartial = $v; - } - - /** - * Initializes the collImages collection. - * - * By default this just sets the collImages collection to an empty array (like clearcollImages()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initImages($overrideExisting = true) - { - if (null !== $this->collImages && !$overrideExisting) { - return; - } - $this->collImages = new PropelObjectCollection(); - $this->collImages->setModel('Image'); - } - - /** - * Gets an array of Image objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Image[] List of Image objects - * @throws PropelException - */ - public function getImages($criteria = null, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - // return empty collection - $this->initImages(); - } else { - $collImages = ImageQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collImagesPartial && count($collImages)) { - $this->initImages(false); - - foreach($collImages as $obj) { - if (false == $this->collImages->contains($obj)) { - $this->collImages->append($obj); - } - } - - $this->collImagesPartial = true; - } - - $collImages->getInternalIterator()->rewind(); - return $collImages; - } - - if($partial && $this->collImages) { - foreach($this->collImages as $obj) { - if($obj->isNew()) { - $collImages[] = $obj; - } - } - } - - $this->collImages = $collImages; - $this->collImagesPartial = false; - } - } - - return $this->collImages; - } - - /** - * Sets a collection of Image objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $images A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setImages(PropelCollection $images, PropelPDO $con = null) - { - $imagesToDelete = $this->getImages(new Criteria(), $con)->diff($images); - - $this->imagesScheduledForDeletion = unserialize(serialize($imagesToDelete)); - - foreach ($imagesToDelete as $imageRemoved) { - $imageRemoved->setProduct(null); - } - - $this->collImages = null; - foreach ($images as $image) { - $this->addImage($image); - } - - $this->collImages = $images; - $this->collImagesPartial = false; - - return $this; - } - - /** - * Returns the number of related Image objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Image objects. - * @throws PropelException - */ - public function countImages(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collImagesPartial && !$this->isNew(); - if (null === $this->collImages || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collImages) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getImages()); - } - $query = ImageQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collImages); - } - - /** - * Method called to associate a Image object to this object - * through the Image foreign key attribute. - * - * @param Image $l Image - * @return Product The current object (for fluent API support) - */ - public function addImage(Image $l) - { - if ($this->collImages === null) { - $this->initImages(); - $this->collImagesPartial = true; - } - if (!in_array($l, $this->collImages->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddImage($l); - } - - return $this; - } - - /** - * @param Image $image The image object to add. - */ - protected function doAddImage($image) - { - $this->collImages[]= $image; - $image->setProduct($this); - } - - /** - * @param Image $image The image object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeImage($image) - { - if ($this->getImages()->contains($image)) { - $this->collImages->remove($this->collImages->search($image)); - if (null === $this->imagesScheduledForDeletion) { - $this->imagesScheduledForDeletion = clone $this->collImages; - $this->imagesScheduledForDeletion->clear(); - } - $this->imagesScheduledForDeletion[]= $image; - $image->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getImages($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Images from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Image[] List of Image objects - */ - public function getImagesJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = ImageQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getImages($query, $con); - } - - /** - * Clears out the collDocuments collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addDocuments() - */ - public function clearDocuments() - { - $this->collDocuments = null; // important to set this to null since that means it is uninitialized - $this->collDocumentsPartial = null; - - return $this; - } - - /** - * reset is the collDocuments collection loaded partially - * - * @return void - */ - public function resetPartialDocuments($v = true) - { - $this->collDocumentsPartial = $v; - } - - /** - * Initializes the collDocuments collection. - * - * By default this just sets the collDocuments collection to an empty array (like clearcollDocuments()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initDocuments($overrideExisting = true) - { - if (null !== $this->collDocuments && !$overrideExisting) { - return; - } - $this->collDocuments = new PropelObjectCollection(); - $this->collDocuments->setModel('Document'); - } - - /** - * Gets an array of Document objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Document[] List of Document objects - * @throws PropelException - */ - public function getDocuments($criteria = null, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - // return empty collection - $this->initDocuments(); - } else { - $collDocuments = DocumentQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collDocumentsPartial && count($collDocuments)) { - $this->initDocuments(false); - - foreach($collDocuments as $obj) { - if (false == $this->collDocuments->contains($obj)) { - $this->collDocuments->append($obj); - } - } - - $this->collDocumentsPartial = true; - } - - $collDocuments->getInternalIterator()->rewind(); - return $collDocuments; - } - - if($partial && $this->collDocuments) { - foreach($this->collDocuments as $obj) { - if($obj->isNew()) { - $collDocuments[] = $obj; - } - } - } - - $this->collDocuments = $collDocuments; - $this->collDocumentsPartial = false; - } - } - - return $this->collDocuments; - } - - /** - * Sets a collection of Document objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $documents A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setDocuments(PropelCollection $documents, PropelPDO $con = null) - { - $documentsToDelete = $this->getDocuments(new Criteria(), $con)->diff($documents); - - $this->documentsScheduledForDeletion = unserialize(serialize($documentsToDelete)); - - foreach ($documentsToDelete as $documentRemoved) { - $documentRemoved->setProduct(null); - } - - $this->collDocuments = null; - foreach ($documents as $document) { - $this->addDocument($document); - } - - $this->collDocuments = $documents; - $this->collDocumentsPartial = false; - - return $this; - } - - /** - * Returns the number of related Document objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Document objects. - * @throws PropelException - */ - public function countDocuments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collDocumentsPartial && !$this->isNew(); - if (null === $this->collDocuments || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collDocuments) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getDocuments()); - } - $query = DocumentQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collDocuments); - } - - /** - * Method called to associate a Document object to this object - * through the Document foreign key attribute. - * - * @param Document $l Document - * @return Product The current object (for fluent API support) - */ - public function addDocument(Document $l) - { - if ($this->collDocuments === null) { - $this->initDocuments(); - $this->collDocumentsPartial = true; - } - if (!in_array($l, $this->collDocuments->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddDocument($l); - } - - return $this; - } - - /** - * @param Document $document The document object to add. - */ - protected function doAddDocument($document) - { - $this->collDocuments[]= $document; - $document->setProduct($this); - } - - /** - * @param Document $document The document object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeDocument($document) - { - if ($this->getDocuments()->contains($document)) { - $this->collDocuments->remove($this->collDocuments->search($document)); - if (null === $this->documentsScheduledForDeletion) { - $this->documentsScheduledForDeletion = clone $this->collDocuments; - $this->documentsScheduledForDeletion->clear(); - } - $this->documentsScheduledForDeletion[]= $document; - $document->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getDocuments($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Documents from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Document[] List of Document objects - */ - public function getDocumentsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = DocumentQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getDocuments($query, $con); - } - - /** - * Clears out the collAccessorysRelatedByProductId collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addAccessorysRelatedByProductId() - */ - public function clearAccessorysRelatedByProductId() - { - $this->collAccessorysRelatedByProductId = null; // important to set this to null since that means it is uninitialized - $this->collAccessorysRelatedByProductIdPartial = null; - - return $this; - } - - /** - * reset is the collAccessorysRelatedByProductId collection loaded partially - * - * @return void - */ - public function resetPartialAccessorysRelatedByProductId($v = true) - { - $this->collAccessorysRelatedByProductIdPartial = $v; - } - - /** - * Initializes the collAccessorysRelatedByProductId collection. - * - * By default this just sets the collAccessorysRelatedByProductId collection to an empty array (like clearcollAccessorysRelatedByProductId()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAccessorysRelatedByProductId($overrideExisting = true) - { - if (null !== $this->collAccessorysRelatedByProductId && !$overrideExisting) { - return; - } - $this->collAccessorysRelatedByProductId = new PropelObjectCollection(); - $this->collAccessorysRelatedByProductId->setModel('Accessory'); - } - - /** - * Gets an array of Accessory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Accessory[] List of Accessory objects - * @throws PropelException - */ - public function getAccessorysRelatedByProductId($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) { - // return empty collection - $this->initAccessorysRelatedByProductId(); - } else { - $collAccessorysRelatedByProductId = AccessoryQuery::create(null, $criteria) - ->filterByProductRelatedByProductId($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAccessorysRelatedByProductIdPartial && count($collAccessorysRelatedByProductId)) { - $this->initAccessorysRelatedByProductId(false); - - foreach($collAccessorysRelatedByProductId as $obj) { - if (false == $this->collAccessorysRelatedByProductId->contains($obj)) { - $this->collAccessorysRelatedByProductId->append($obj); - } - } - - $this->collAccessorysRelatedByProductIdPartial = true; - } - - $collAccessorysRelatedByProductId->getInternalIterator()->rewind(); - return $collAccessorysRelatedByProductId; - } - - if($partial && $this->collAccessorysRelatedByProductId) { - foreach($this->collAccessorysRelatedByProductId as $obj) { - if($obj->isNew()) { - $collAccessorysRelatedByProductId[] = $obj; - } - } - } - - $this->collAccessorysRelatedByProductId = $collAccessorysRelatedByProductId; - $this->collAccessorysRelatedByProductIdPartial = false; - } - } - - return $this->collAccessorysRelatedByProductId; - } - - /** - * Sets a collection of AccessoryRelatedByProductId objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $accessorysRelatedByProductId A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setAccessorysRelatedByProductId(PropelCollection $accessorysRelatedByProductId, PropelPDO $con = null) - { - $accessorysRelatedByProductIdToDelete = $this->getAccessorysRelatedByProductId(new Criteria(), $con)->diff($accessorysRelatedByProductId); - - $this->accessorysRelatedByProductIdScheduledForDeletion = unserialize(serialize($accessorysRelatedByProductIdToDelete)); - - foreach ($accessorysRelatedByProductIdToDelete as $accessoryRelatedByProductIdRemoved) { - $accessoryRelatedByProductIdRemoved->setProductRelatedByProductId(null); - } - - $this->collAccessorysRelatedByProductId = null; - foreach ($accessorysRelatedByProductId as $accessoryRelatedByProductId) { - $this->addAccessoryRelatedByProductId($accessoryRelatedByProductId); - } - - $this->collAccessorysRelatedByProductId = $accessorysRelatedByProductId; - $this->collAccessorysRelatedByProductIdPartial = false; - - return $this; - } - - /** - * Returns the number of related Accessory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Accessory objects. - * @throws PropelException - */ - public function countAccessorysRelatedByProductId(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAccessorysRelatedByProductIdPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByProductId || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByProductId) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByProductId()); - } - $query = AccessoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByProductId($this) - ->count($con); - } - - return count($this->collAccessorysRelatedByProductId); - } - - /** - * Method called to associate a Accessory object to this object - * through the Accessory foreign key attribute. - * - * @param Accessory $l Accessory - * @return Product The current object (for fluent API support) - */ - public function addAccessoryRelatedByProductId(Accessory $l) - { - if ($this->collAccessorysRelatedByProductId === null) { - $this->initAccessorysRelatedByProductId(); - $this->collAccessorysRelatedByProductIdPartial = true; - } - if (!in_array($l, $this->collAccessorysRelatedByProductId->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAccessoryRelatedByProductId($l); - } - - return $this; - } - - /** - * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to add. - */ - protected function doAddAccessoryRelatedByProductId($accessoryRelatedByProductId) - { - $this->collAccessorysRelatedByProductId[]= $accessoryRelatedByProductId; - $accessoryRelatedByProductId->setProductRelatedByProductId($this); - } - - /** - * @param AccessoryRelatedByProductId $accessoryRelatedByProductId The accessoryRelatedByProductId object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeAccessoryRelatedByProductId($accessoryRelatedByProductId) - { - if ($this->getAccessorysRelatedByProductId()->contains($accessoryRelatedByProductId)) { - $this->collAccessorysRelatedByProductId->remove($this->collAccessorysRelatedByProductId->search($accessoryRelatedByProductId)); - if (null === $this->accessorysRelatedByProductIdScheduledForDeletion) { - $this->accessorysRelatedByProductIdScheduledForDeletion = clone $this->collAccessorysRelatedByProductId; - $this->accessorysRelatedByProductIdScheduledForDeletion->clear(); - } - $this->accessorysRelatedByProductIdScheduledForDeletion[]= clone $accessoryRelatedByProductId; - $accessoryRelatedByProductId->setProductRelatedByProductId(null); - } - - return $this; - } - - /** - * Clears out the collAccessorysRelatedByAccessory collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addAccessorysRelatedByAccessory() - */ - public function clearAccessorysRelatedByAccessory() - { - $this->collAccessorysRelatedByAccessory = null; // important to set this to null since that means it is uninitialized - $this->collAccessorysRelatedByAccessoryPartial = null; - - return $this; - } - - /** - * reset is the collAccessorysRelatedByAccessory collection loaded partially - * - * @return void - */ - public function resetPartialAccessorysRelatedByAccessory($v = true) - { - $this->collAccessorysRelatedByAccessoryPartial = $v; - } - - /** - * Initializes the collAccessorysRelatedByAccessory collection. - * - * By default this just sets the collAccessorysRelatedByAccessory collection to an empty array (like clearcollAccessorysRelatedByAccessory()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAccessorysRelatedByAccessory($overrideExisting = true) - { - if (null !== $this->collAccessorysRelatedByAccessory && !$overrideExisting) { - return; - } - $this->collAccessorysRelatedByAccessory = new PropelObjectCollection(); - $this->collAccessorysRelatedByAccessory->setModel('Accessory'); - } - - /** - * Gets an array of Accessory objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Accessory[] List of Accessory objects - * @throws PropelException - */ - public function getAccessorysRelatedByAccessory($criteria = null, PropelPDO $con = null) - { - $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) { - // return empty collection - $this->initAccessorysRelatedByAccessory(); - } else { - $collAccessorysRelatedByAccessory = AccessoryQuery::create(null, $criteria) - ->filterByProductRelatedByAccessory($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collAccessorysRelatedByAccessoryPartial && count($collAccessorysRelatedByAccessory)) { - $this->initAccessorysRelatedByAccessory(false); - - foreach($collAccessorysRelatedByAccessory as $obj) { - if (false == $this->collAccessorysRelatedByAccessory->contains($obj)) { - $this->collAccessorysRelatedByAccessory->append($obj); - } - } - - $this->collAccessorysRelatedByAccessoryPartial = true; - } - - $collAccessorysRelatedByAccessory->getInternalIterator()->rewind(); - return $collAccessorysRelatedByAccessory; - } - - if($partial && $this->collAccessorysRelatedByAccessory) { - foreach($this->collAccessorysRelatedByAccessory as $obj) { - if($obj->isNew()) { - $collAccessorysRelatedByAccessory[] = $obj; - } - } - } - - $this->collAccessorysRelatedByAccessory = $collAccessorysRelatedByAccessory; - $this->collAccessorysRelatedByAccessoryPartial = false; - } - } - - return $this->collAccessorysRelatedByAccessory; - } - - /** - * Sets a collection of AccessoryRelatedByAccessory objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $accessorysRelatedByAccessory A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setAccessorysRelatedByAccessory(PropelCollection $accessorysRelatedByAccessory, PropelPDO $con = null) - { - $accessorysRelatedByAccessoryToDelete = $this->getAccessorysRelatedByAccessory(new Criteria(), $con)->diff($accessorysRelatedByAccessory); - - $this->accessorysRelatedByAccessoryScheduledForDeletion = unserialize(serialize($accessorysRelatedByAccessoryToDelete)); - - foreach ($accessorysRelatedByAccessoryToDelete as $accessoryRelatedByAccessoryRemoved) { - $accessoryRelatedByAccessoryRemoved->setProductRelatedByAccessory(null); - } - - $this->collAccessorysRelatedByAccessory = null; - foreach ($accessorysRelatedByAccessory as $accessoryRelatedByAccessory) { - $this->addAccessoryRelatedByAccessory($accessoryRelatedByAccessory); - } - - $this->collAccessorysRelatedByAccessory = $accessorysRelatedByAccessory; - $this->collAccessorysRelatedByAccessoryPartial = false; - - return $this; - } - - /** - * Returns the number of related Accessory objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Accessory objects. - * @throws PropelException - */ - public function countAccessorysRelatedByAccessory(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collAccessorysRelatedByAccessoryPartial && !$this->isNew(); - if (null === $this->collAccessorysRelatedByAccessory || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAccessorysRelatedByAccessory) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getAccessorysRelatedByAccessory()); - } - $query = AccessoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByAccessory($this) - ->count($con); - } - - return count($this->collAccessorysRelatedByAccessory); - } - - /** - * Method called to associate a Accessory object to this object - * through the Accessory foreign key attribute. - * - * @param Accessory $l Accessory - * @return Product The current object (for fluent API support) - */ - public function addAccessoryRelatedByAccessory(Accessory $l) - { - if ($this->collAccessorysRelatedByAccessory === null) { - $this->initAccessorysRelatedByAccessory(); - $this->collAccessorysRelatedByAccessoryPartial = true; - } - if (!in_array($l, $this->collAccessorysRelatedByAccessory->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAccessoryRelatedByAccessory($l); - } - - return $this; - } - - /** - * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to add. - */ - protected function doAddAccessoryRelatedByAccessory($accessoryRelatedByAccessory) - { - $this->collAccessorysRelatedByAccessory[]= $accessoryRelatedByAccessory; - $accessoryRelatedByAccessory->setProductRelatedByAccessory($this); - } - - /** - * @param AccessoryRelatedByAccessory $accessoryRelatedByAccessory The accessoryRelatedByAccessory object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeAccessoryRelatedByAccessory($accessoryRelatedByAccessory) - { - if ($this->getAccessorysRelatedByAccessory()->contains($accessoryRelatedByAccessory)) { - $this->collAccessorysRelatedByAccessory->remove($this->collAccessorysRelatedByAccessory->search($accessoryRelatedByAccessory)); - if (null === $this->accessorysRelatedByAccessoryScheduledForDeletion) { - $this->accessorysRelatedByAccessoryScheduledForDeletion = clone $this->collAccessorysRelatedByAccessory; - $this->accessorysRelatedByAccessoryScheduledForDeletion->clear(); - } - $this->accessorysRelatedByAccessoryScheduledForDeletion[]= clone $accessoryRelatedByAccessory; - $accessoryRelatedByAccessory->setProductRelatedByAccessory(null); - } - - return $this; - } - - /** - * Clears out the collRewritings collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Product The current object (for fluent API support) - * @see addRewritings() - */ - public function clearRewritings() - { - $this->collRewritings = null; // important to set this to null since that means it is uninitialized - $this->collRewritingsPartial = null; - - return $this; - } - - /** - * reset is the collRewritings collection loaded partially - * - * @return void - */ - public function resetPartialRewritings($v = true) - { - $this->collRewritingsPartial = $v; - } - - /** - * Initializes the collRewritings collection. - * - * By default this just sets the collRewritings collection to an empty array (like clearcollRewritings()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initRewritings($overrideExisting = true) - { - if (null !== $this->collRewritings && !$overrideExisting) { - return; - } - $this->collRewritings = new PropelObjectCollection(); - $this->collRewritings->setModel('Rewriting'); - } - - /** - * Gets an array of Rewriting objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Product is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - * @throws PropelException - */ - public function getRewritings($criteria = null, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - // return empty collection - $this->initRewritings(); - } else { - $collRewritings = RewritingQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collRewritingsPartial && count($collRewritings)) { - $this->initRewritings(false); - - foreach($collRewritings as $obj) { - if (false == $this->collRewritings->contains($obj)) { - $this->collRewritings->append($obj); - } - } - - $this->collRewritingsPartial = true; - } - - $collRewritings->getInternalIterator()->rewind(); - return $collRewritings; - } - - if($partial && $this->collRewritings) { - foreach($this->collRewritings as $obj) { - if($obj->isNew()) { - $collRewritings[] = $obj; - } - } - } - - $this->collRewritings = $collRewritings; - $this->collRewritingsPartial = false; - } - } - - return $this->collRewritings; - } - - /** - * Sets a collection of Rewriting objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $rewritings A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setRewritings(PropelCollection $rewritings, PropelPDO $con = null) - { - $rewritingsToDelete = $this->getRewritings(new Criteria(), $con)->diff($rewritings); - - $this->rewritingsScheduledForDeletion = unserialize(serialize($rewritingsToDelete)); - - foreach ($rewritingsToDelete as $rewritingRemoved) { - $rewritingRemoved->setProduct(null); - } - - $this->collRewritings = null; - foreach ($rewritings as $rewriting) { - $this->addRewriting($rewriting); - } - - $this->collRewritings = $rewritings; - $this->collRewritingsPartial = false; - - return $this; - } - - /** - * Returns the number of related Rewriting objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Rewriting objects. - * @throws PropelException - */ - public function countRewritings(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collRewritingsPartial && !$this->isNew(); - if (null === $this->collRewritings || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collRewritings) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getRewritings()); - } - $query = RewritingQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collRewritings); - } - - /** - * Method called to associate a Rewriting object to this object - * through the Rewriting foreign key attribute. - * - * @param Rewriting $l Rewriting - * @return Product The current object (for fluent API support) - */ - public function addRewriting(Rewriting $l) - { - if ($this->collRewritings === null) { - $this->initRewritings(); - $this->collRewritingsPartial = true; - } - if (!in_array($l, $this->collRewritings->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddRewriting($l); - } - - return $this; - } - - /** - * @param Rewriting $rewriting The rewriting object to add. - */ - protected function doAddRewriting($rewriting) - { - $this->collRewritings[]= $rewriting; - $rewriting->setProduct($this); - } - - /** - * @param Rewriting $rewriting The rewriting object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeRewriting($rewriting) - { - if ($this->getRewritings()->contains($rewriting)) { - $this->collRewritings->remove($this->collRewritings->search($rewriting)); - if (null === $this->rewritingsScheduledForDeletion) { - $this->rewritingsScheduledForDeletion = clone $this->collRewritings; - $this->rewritingsScheduledForDeletion->clear(); - } - $this->rewritingsScheduledForDeletion[]= $rewriting; - $rewriting->setProduct(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinCategory($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Category', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinFolder($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Folder', $join_behavior); - - return $this->getRewritings($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Product is new, it will return - * an empty collection; or if this Product has previously - * been saved, it will retrieve related Rewritings from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Product. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|Rewriting[] List of Rewriting objects - */ - public function getRewritingsJoinContent($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = RewritingQuery::create(null, $criteria); - $query->joinWith('Content', $join_behavior); - - return $this->getRewritings($query, $con); - } - - /** - * Clears out the collProductI18ns 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 Product The current object (for fluent API support) - * @see addProductI18ns() - */ - public function clearProductI18ns() - { - $this->collProductI18ns = null; // important to set this to null since that means it is uninitialized - $this->collProductI18nsPartial = null; - - return $this; - } - - /** - * reset is the collProductI18ns collection loaded partially - * - * @return void - */ - public function resetPartialProductI18ns($v = true) - { - $this->collProductI18nsPartial = $v; - } - - /** - * Initializes the collProductI18ns collection. - * - * By default this just sets the collProductI18ns collection to an empty array (like clearcollProductI18ns()); - * 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 initProductI18ns($overrideExisting = true) - { - if (null !== $this->collProductI18ns && !$overrideExisting) { - return; - } - $this->collProductI18ns = new PropelObjectCollection(); - $this->collProductI18ns->setModel('ProductI18n'); - } - - /** - * Gets an array of ProductI18n 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|ProductI18n[] List of ProductI18n objects - * @throws PropelException - */ - public function getProductI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductI18nsPartial && !$this->isNew(); - if (null === $this->collProductI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductI18ns) { - // return empty collection - $this->initProductI18ns(); - } else { - $collProductI18ns = ProductI18nQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductI18nsPartial && count($collProductI18ns)) { - $this->initProductI18ns(false); - - foreach($collProductI18ns as $obj) { - if (false == $this->collProductI18ns->contains($obj)) { - $this->collProductI18ns->append($obj); - } - } - - $this->collProductI18nsPartial = true; - } - - $collProductI18ns->getInternalIterator()->rewind(); - return $collProductI18ns; - } - - if($partial && $this->collProductI18ns) { - foreach($this->collProductI18ns as $obj) { - if($obj->isNew()) { - $collProductI18ns[] = $obj; - } - } - } - - $this->collProductI18ns = $collProductI18ns; - $this->collProductI18nsPartial = false; - } - } - - return $this->collProductI18ns; - } - - /** - * Sets a collection of ProductI18n 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 $productI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setProductI18ns(PropelCollection $productI18ns, PropelPDO $con = null) - { - $productI18nsToDelete = $this->getProductI18ns(new Criteria(), $con)->diff($productI18ns); - - $this->productI18nsScheduledForDeletion = unserialize(serialize($productI18nsToDelete)); - - foreach ($productI18nsToDelete as $productI18nRemoved) { - $productI18nRemoved->setProduct(null); - } - - $this->collProductI18ns = null; - foreach ($productI18ns as $productI18n) { - $this->addProductI18n($productI18n); - } - - $this->collProductI18ns = $productI18ns; - $this->collProductI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ProductI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ProductI18n objects. - * @throws PropelException - */ - public function countProductI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductI18nsPartial && !$this->isNew(); - if (null === $this->collProductI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProductI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getProductI18ns()); - } - $query = ProductI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collProductI18ns); - } - - /** - * Method called to associate a ProductI18n object to this object - * through the ProductI18n foreign key attribute. - * - * @param ProductI18n $l ProductI18n - * @return Product The current object (for fluent API support) - */ - public function addProductI18n(ProductI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collProductI18ns === null) { - $this->initProductI18ns(); - $this->collProductI18nsPartial = true; - } - if (!in_array($l, $this->collProductI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddProductI18n($l); - } - - return $this; - } - - /** - * @param ProductI18n $productI18n The productI18n object to add. - */ - protected function doAddProductI18n($productI18n) - { - $this->collProductI18ns[]= $productI18n; - $productI18n->setProduct($this); - } - - /** - * @param ProductI18n $productI18n The productI18n object to remove. - * @return Product The current object (for fluent API support) - */ - public function removeProductI18n($productI18n) - { - if ($this->getProductI18ns()->contains($productI18n)) { - $this->collProductI18ns->remove($this->collProductI18ns->search($productI18n)); - if (null === $this->productI18nsScheduledForDeletion) { - $this->productI18nsScheduledForDeletion = clone $this->collProductI18ns; - $this->productI18nsScheduledForDeletion->clear(); - } - $this->productI18nsScheduledForDeletion[]= clone $productI18n; - $productI18n->setProduct(null); - } - - return $this; - } - - /** - * 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 Product The current object (for fluent API support) - * @see addProductVersions() - */ - public function clearProductVersions() - { - $this->collProductVersions = null; // important to set this to null since that means it is uninitialized - $this->collProductVersionsPartial = null; - - return $this; - } - - /** - * 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; - } - - $collProductVersions->getInternalIterator()->rewind(); - 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 - * @return Product The current object (for fluent API support) - */ - public function setProductVersions(PropelCollection $productVersions, PropelPDO $con = null) - { - $productVersionsToDelete = $this->getProductVersions(new Criteria(), $con)->diff($productVersions); - - $this->productVersionsScheduledForDeletion = unserialize(serialize($productVersionsToDelete)); - - foreach ($productVersionsToDelete as $productVersionRemoved) { - $productVersionRemoved->setProduct(null); - } - - $this->collProductVersions = null; - foreach ($productVersions as $productVersion) { - $this->addProductVersion($productVersion); - } - - $this->collProductVersions = $productVersions; - $this->collProductVersionsPartial = false; - - return $this; - } - - /** - * 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; - } - - if($partial && !$criteria) { - return count($this->getProductVersions()); - } - $query = ProductVersionQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - - return count($this->collProductVersions); - } - - /** - * 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 (!in_array($l, $this->collProductVersions->getArrayCopy(), true)) { // 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. - * @return Product The current object (for fluent API support) - */ - 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[]= clone $productVersion; - $productVersion->setProduct(null); - } - - return $this; - } - - /** - * Clears out the collCategorys 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 Product The current object (for fluent API support) - * @see addCategorys() - */ - public function clearCategorys() - { - $this->collCategorys = null; // important to set this to null since that means it is uninitialized - $this->collCategorysPartial = null; - - return $this; - } - - /** - * Initializes the collCategorys collection. - * - * By default this just sets the collCategorys collection to an empty collection (like clearCategorys()); - * 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. - * - * @return void - */ - public function initCategorys() - { - $this->collCategorys = new PropelObjectCollection(); - $this->collCategorys->setModel('Category'); - } - - /** - * Gets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Category[] List of Category objects - */ - public function getCategorys($criteria = null, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - // return empty collection - $this->initCategorys(); - } else { - $collCategorys = CategoryQuery::create(null, $criteria) - ->filterByProduct($this) - ->find($con); - if (null !== $criteria) { - return $collCategorys; - } - $this->collCategorys = $collCategorys; - } - } - - return $this->collCategorys; - } - - /** - * Sets a collection of Category objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * 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 $categorys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setCategorys(PropelCollection $categorys, PropelPDO $con = null) - { - $this->clearCategorys(); - $currentCategorys = $this->getCategorys(); - - $this->categorysScheduledForDeletion = $currentCategorys->diff($categorys); - - foreach ($categorys as $category) { - if (!$currentCategorys->contains($category)) { - $this->doAddCategory($category); - } - } - - $this->collCategorys = $categorys; - - return $this; - } - - /** - * Gets the number of Category objects related by a many-to-many relationship - * to the current object by way of the product_category cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Category objects - */ - public function countCategorys($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collCategorys || null !== $criteria) { - if ($this->isNew() && null === $this->collCategorys) { - return 0; - } else { - $query = CategoryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProduct($this) - ->count($con); - } - } else { - return count($this->collCategorys); - } - } - - /** - * Associate a Category object to this object - * through the product_category cross reference table. - * - * @param Category $category The ProductCategory object to relate - * @return Product The current object (for fluent API support) - */ - public function addCategory(Category $category) - { - if ($this->collCategorys === null) { - $this->initCategorys(); - } - if (!$this->collCategorys->contains($category)) { // only add it if the **same** object is not already associated - $this->doAddCategory($category); - - $this->collCategorys[]= $category; - } - - return $this; - } - - /** - * @param Category $category The category object to add. - */ - protected function doAddCategory($category) - { - $productCategory = new ProductCategory(); - $productCategory->setCategory($category); - $this->addProductCategory($productCategory); - } - - /** - * Remove a Category object to this object - * through the product_category cross reference table. - * - * @param Category $category The ProductCategory object to relate - * @return Product The current object (for fluent API support) - */ - public function removeCategory(Category $category) - { - if ($this->getCategorys()->contains($category)) { - $this->collCategorys->remove($this->collCategorys->search($category)); - if (null === $this->categorysScheduledForDeletion) { - $this->categorysScheduledForDeletion = clone $this->collCategorys; - $this->categorysScheduledForDeletion->clear(); - } - $this->categorysScheduledForDeletion[]= $category; - } - - return $this; - } - - /** - * Clears out the collProductsRelatedByAccessory 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 Product The current object (for fluent API support) - * @see addProductsRelatedByAccessory() - */ - public function clearProductsRelatedByAccessory() - { - $this->collProductsRelatedByAccessory = null; // important to set this to null since that means it is uninitialized - $this->collProductsRelatedByAccessoryPartial = null; - - return $this; - } - - /** - * Initializes the collProductsRelatedByAccessory collection. - * - * By default this just sets the collProductsRelatedByAccessory collection to an empty collection (like clearProductsRelatedByAccessory()); - * 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. - * - * @return void - */ - public function initProductsRelatedByAccessory() - { - $this->collProductsRelatedByAccessory = new PropelObjectCollection(); - $this->collProductsRelatedByAccessory->setModel('Product'); - } - - /** - * Gets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Product[] List of Product objects - */ - public function getProductsRelatedByAccessory($criteria = null, PropelPDO $con = null) - { - if (null === $this->collProductsRelatedByAccessory || null !== $criteria) { - if ($this->isNew() && null === $this->collProductsRelatedByAccessory) { - // return empty collection - $this->initProductsRelatedByAccessory(); - } else { - $collProductsRelatedByAccessory = ProductQuery::create(null, $criteria) - ->filterByProductRelatedByProductId($this) - ->find($con); - if (null !== $criteria) { - return $collProductsRelatedByAccessory; - } - $this->collProductsRelatedByAccessory = $collProductsRelatedByAccessory; - } - } - - return $this->collProductsRelatedByAccessory; - } - - /** - * Sets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * 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 $productsRelatedByAccessory A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setProductsRelatedByAccessory(PropelCollection $productsRelatedByAccessory, PropelPDO $con = null) - { - $this->clearProductsRelatedByAccessory(); - $currentProductsRelatedByAccessory = $this->getProductsRelatedByAccessory(); - - $this->productsRelatedByAccessoryScheduledForDeletion = $currentProductsRelatedByAccessory->diff($productsRelatedByAccessory); - - foreach ($productsRelatedByAccessory as $productRelatedByAccessory) { - if (!$currentProductsRelatedByAccessory->contains($productRelatedByAccessory)) { - $this->doAddProductRelatedByAccessory($productRelatedByAccessory); - } - } - - $this->collProductsRelatedByAccessory = $productsRelatedByAccessory; - - return $this; - } - - /** - * Gets the number of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Product objects - */ - public function countProductsRelatedByAccessory($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collProductsRelatedByAccessory || null !== $criteria) { - if ($this->isNew() && null === $this->collProductsRelatedByAccessory) { - return 0; - } else { - $query = ProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByProductId($this) - ->count($con); - } - } else { - return count($this->collProductsRelatedByAccessory); - } - } - - /** - * Associate a Product object to this object - * through the accessory cross reference table. - * - * @param Product $product The Accessory object to relate - * @return Product The current object (for fluent API support) - */ - public function addProductRelatedByAccessory(Product $product) - { - if ($this->collProductsRelatedByAccessory === null) { - $this->initProductsRelatedByAccessory(); - } - if (!$this->collProductsRelatedByAccessory->contains($product)) { // only add it if the **same** object is not already associated - $this->doAddProductRelatedByAccessory($product); - - $this->collProductsRelatedByAccessory[]= $product; - } - - return $this; - } - - /** - * @param ProductRelatedByAccessory $productRelatedByAccessory The productRelatedByAccessory object to add. - */ - protected function doAddProductRelatedByAccessory($productRelatedByAccessory) - { - $accessory = new Accessory(); - $accessory->setProductRelatedByAccessory($productRelatedByAccessory); - $this->addAccessoryRelatedByProductId($accessory); - } - - /** - * Remove a Product object to this object - * through the accessory cross reference table. - * - * @param Product $product The Accessory object to relate - * @return Product The current object (for fluent API support) - */ - public function removeProductRelatedByAccessory(Product $product) - { - if ($this->getProductsRelatedByAccessory()->contains($product)) { - $this->collProductsRelatedByAccessory->remove($this->collProductsRelatedByAccessory->search($product)); - if (null === $this->productsRelatedByAccessoryScheduledForDeletion) { - $this->productsRelatedByAccessoryScheduledForDeletion = clone $this->collProductsRelatedByAccessory; - $this->productsRelatedByAccessoryScheduledForDeletion->clear(); - } - $this->productsRelatedByAccessoryScheduledForDeletion[]= $product; - } - - return $this; - } - - /** - * Clears out the collProductsRelatedByProductId 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 Product The current object (for fluent API support) - * @see addProductsRelatedByProductId() - */ - public function clearProductsRelatedByProductId() - { - $this->collProductsRelatedByProductId = null; // important to set this to null since that means it is uninitialized - $this->collProductsRelatedByProductIdPartial = null; - - return $this; - } - - /** - * Initializes the collProductsRelatedByProductId collection. - * - * By default this just sets the collProductsRelatedByProductId collection to an empty collection (like clearProductsRelatedByProductId()); - * 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. - * - * @return void - */ - public function initProductsRelatedByProductId() - { - $this->collProductsRelatedByProductId = new PropelObjectCollection(); - $this->collProductsRelatedByProductId->setModel('Product'); - } - - /** - * Gets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * - * 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 query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Product[] List of Product objects - */ - public function getProductsRelatedByProductId($criteria = null, PropelPDO $con = null) - { - if (null === $this->collProductsRelatedByProductId || null !== $criteria) { - if ($this->isNew() && null === $this->collProductsRelatedByProductId) { - // return empty collection - $this->initProductsRelatedByProductId(); - } else { - $collProductsRelatedByProductId = ProductQuery::create(null, $criteria) - ->filterByProductRelatedByAccessory($this) - ->find($con); - if (null !== $criteria) { - return $collProductsRelatedByProductId; - } - $this->collProductsRelatedByProductId = $collProductsRelatedByProductId; - } - } - - return $this->collProductsRelatedByProductId; - } - - /** - * Sets a collection of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * 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 $productsRelatedByProductId A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Product The current object (for fluent API support) - */ - public function setProductsRelatedByProductId(PropelCollection $productsRelatedByProductId, PropelPDO $con = null) - { - $this->clearProductsRelatedByProductId(); - $currentProductsRelatedByProductId = $this->getProductsRelatedByProductId(); - - $this->productsRelatedByProductIdScheduledForDeletion = $currentProductsRelatedByProductId->diff($productsRelatedByProductId); - - foreach ($productsRelatedByProductId as $productRelatedByProductId) { - if (!$currentProductsRelatedByProductId->contains($productRelatedByProductId)) { - $this->doAddProductRelatedByProductId($productRelatedByProductId); - } - } - - $this->collProductsRelatedByProductId = $productsRelatedByProductId; - - return $this; - } - - /** - * Gets the number of Product objects related by a many-to-many relationship - * to the current object by way of the accessory cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Product objects - */ - public function countProductsRelatedByProductId($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collProductsRelatedByProductId || null !== $criteria) { - if ($this->isNew() && null === $this->collProductsRelatedByProductId) { - return 0; - } else { - $query = ProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByProductRelatedByAccessory($this) - ->count($con); - } - } else { - return count($this->collProductsRelatedByProductId); - } - } - - /** - * Associate a Product object to this object - * through the accessory cross reference table. - * - * @param Product $product The Accessory object to relate - * @return Product The current object (for fluent API support) - */ - public function addProductRelatedByProductId(Product $product) - { - if ($this->collProductsRelatedByProductId === null) { - $this->initProductsRelatedByProductId(); - } - if (!$this->collProductsRelatedByProductId->contains($product)) { // only add it if the **same** object is not already associated - $this->doAddProductRelatedByProductId($product); - - $this->collProductsRelatedByProductId[]= $product; - } - - return $this; - } - - /** - * @param ProductRelatedByProductId $productRelatedByProductId The productRelatedByProductId object to add. - */ - protected function doAddProductRelatedByProductId($productRelatedByProductId) - { - $accessory = new Accessory(); - $accessory->setProductRelatedByProductId($productRelatedByProductId); - $this->addAccessoryRelatedByAccessory($accessory); - } - - /** - * Remove a Product object to this object - * through the accessory cross reference table. - * - * @param Product $product The Accessory object to relate - * @return Product The current object (for fluent API support) - */ - public function removeProductRelatedByProductId(Product $product) - { - if ($this->getProductsRelatedByProductId()->contains($product)) { - $this->collProductsRelatedByProductId->remove($this->collProductsRelatedByProductId->search($product)); - if (null === $this->productsRelatedByProductIdScheduledForDeletion) { - $this->productsRelatedByProductIdScheduledForDeletion = clone $this->collProductsRelatedByProductId; - $this->productsRelatedByProductIdScheduledForDeletion->clear(); - } - $this->productsRelatedByProductIdScheduledForDeletion[]= $product; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->tax_rule_id = null; - $this->ref = null; - $this->price = null; - $this->price2 = null; - $this->ecotax = null; - $this->newness = null; - $this->promo = null; - $this->quantity = null; - $this->visible = null; - $this->weight = null; - $this->position = null; - $this->created_at = null; - $this->updated_at = null; - $this->version = null; - $this->version_created_at = null; - $this->version_created_by = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collProductCategorys) { - foreach ($this->collProductCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collFeatureProds) { - foreach ($this->collFeatureProds as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collStocks) { - foreach ($this->collStocks as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collContentAssocs) { - foreach ($this->collContentAssocs as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collImages) { - foreach ($this->collImages as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collDocuments) { - foreach ($this->collDocuments as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAccessorysRelatedByProductId) { - foreach ($this->collAccessorysRelatedByProductId as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAccessorysRelatedByAccessory) { - foreach ($this->collAccessorysRelatedByAccessory as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collRewritings) { - foreach ($this->collRewritings as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductI18ns) { - foreach ($this->collProductI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductVersions) { - foreach ($this->collProductVersions as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collCategorys) { - foreach ($this->collCategorys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductsRelatedByAccessory) { - foreach ($this->collProductsRelatedByAccessory as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collProductsRelatedByProductId) { - foreach ($this->collProductsRelatedByProductId as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->aTaxRule instanceof Persistent) { - $this->aTaxRule->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collProductCategorys instanceof PropelCollection) { - $this->collProductCategorys->clearIterator(); - } - $this->collProductCategorys = null; - if ($this->collFeatureProds instanceof PropelCollection) { - $this->collFeatureProds->clearIterator(); - } - $this->collFeatureProds = null; - if ($this->collStocks instanceof PropelCollection) { - $this->collStocks->clearIterator(); - } - $this->collStocks = null; - if ($this->collContentAssocs instanceof PropelCollection) { - $this->collContentAssocs->clearIterator(); - } - $this->collContentAssocs = null; - if ($this->collImages instanceof PropelCollection) { - $this->collImages->clearIterator(); - } - $this->collImages = null; - if ($this->collDocuments instanceof PropelCollection) { - $this->collDocuments->clearIterator(); - } - $this->collDocuments = null; - if ($this->collAccessorysRelatedByProductId instanceof PropelCollection) { - $this->collAccessorysRelatedByProductId->clearIterator(); - } - $this->collAccessorysRelatedByProductId = null; - if ($this->collAccessorysRelatedByAccessory instanceof PropelCollection) { - $this->collAccessorysRelatedByAccessory->clearIterator(); - } - $this->collAccessorysRelatedByAccessory = null; - if ($this->collRewritings instanceof PropelCollection) { - $this->collRewritings->clearIterator(); - } - $this->collRewritings = null; - if ($this->collProductI18ns instanceof PropelCollection) { - $this->collProductI18ns->clearIterator(); - } - $this->collProductI18ns = null; - if ($this->collProductVersions instanceof PropelCollection) { - $this->collProductVersions->clearIterator(); - } - $this->collProductVersions = null; - if ($this->collCategorys instanceof PropelCollection) { - $this->collCategorys->clearIterator(); - } - $this->collCategorys = null; - if ($this->collProductsRelatedByAccessory instanceof PropelCollection) { - $this->collProductsRelatedByAccessory->clearIterator(); - } - $this->collProductsRelatedByAccessory = null; - if ($this->collProductsRelatedByProductId instanceof PropelCollection) { - $this->collProductsRelatedByProductId->clearIterator(); - } - $this->collProductsRelatedByProductId = null; - $this->aTaxRule = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ProductPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Product The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ProductPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Product The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ProductI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collProductI18ns) { - foreach ($this->collProductI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ProductI18n(); - $translation->setLocale($locale); - } else { - $translation = ProductI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addProductI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Product The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ProductI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collProductI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collProductI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ProductI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - 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->setQuantity($this->getQuantity()); - $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->setQuantity($version->getQuantity()); - $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/BaseProductCategory.php b/core/lib/Thelia/Model/om/BaseProductCategory.php deleted file mode 100755 index 726ea6384..000000000 --- a/core/lib/Thelia/Model/om/BaseProductCategory.php +++ /dev/null @@ -1,1228 +0,0 @@ -product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return ProductCategory The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = ProductCategoryPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return ProductCategory The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = ProductCategoryPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ProductCategory The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ProductCategoryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return ProductCategory The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ProductCategoryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->product_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->category_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ProductCategory object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ProductCategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aCategory = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ProductCategoryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ProductCategoryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ProductCategoryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(ProductCategoryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `product_category` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - - if (($retval = ProductCategoryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ProductCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getProductId(); - break; - case 1: - return $this->getCategoryId(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ProductCategory'][serialize($this->getPrimaryKey())] = true; - $keys = ProductCategoryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getProductId(), - $keys[1] => $this->getCategoryId(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ProductCategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setProductId($value); - break; - case 1: - $this->setCategoryId($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ProductCategoryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setProductId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCategoryId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME); - - if ($this->isColumnModified(ProductCategoryPeer::PRODUCT_ID)) $criteria->add(ProductCategoryPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(ProductCategoryPeer::CATEGORY_ID)) $criteria->add(ProductCategoryPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(ProductCategoryPeer::CREATED_AT)) $criteria->add(ProductCategoryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ProductCategoryPeer::UPDATED_AT)) $criteria->add(ProductCategoryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME); - $criteria->add(ProductCategoryPeer::PRODUCT_ID, $this->product_id); - $criteria->add(ProductCategoryPeer::CATEGORY_ID, $this->category_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getProductId(); - $pks[1] = $this->getCategoryId(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setProductId($keys[0]); - $this->setCategoryId($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getProductId()) && (null === $this->getCategoryId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of ProductCategory (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return ProductCategory Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ProductCategoryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ProductCategoryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return ProductCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addProductCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addProductCategorys($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return ProductCategory The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addProductCategory($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addProductCategorys($this); - */ - } - - return $this->aCategory; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->product_id = null; - $this->category_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aProduct = null; - $this->aCategory = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ProductCategoryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ProductCategory The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ProductCategoryPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php b/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php deleted file mode 100755 index b564bf650..000000000 --- a/core/lib/Thelia/Model/om/BaseProductCategoryPeer.php +++ /dev/null @@ -1,1400 +0,0 @@ - array ('ProductId', 'CategoryId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('productId', 'categoryId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID, ProductCategoryPeer::CATEGORY_ID, ProductCategoryPeer::CREATED_AT, ProductCategoryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID', 'CATEGORY_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('product_id', 'category_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ProductCategoryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('ProductId' => 0, 'CategoryId' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('productId' => 0, 'categoryId' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (ProductCategoryPeer::PRODUCT_ID => 0, ProductCategoryPeer::CATEGORY_ID => 1, ProductCategoryPeer::CREATED_AT => 2, ProductCategoryPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('PRODUCT_ID' => 0, 'CATEGORY_ID' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('product_id' => 0, 'category_id' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ProductCategoryPeer::getFieldNames($toType); - $key = isset(ProductCategoryPeer::$fieldKeys[$fromType][$name]) ? ProductCategoryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ProductCategoryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ProductCategoryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ProductCategoryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ProductCategoryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ProductCategoryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ProductCategoryPeer::PRODUCT_ID); - $criteria->addSelectColumn(ProductCategoryPeer::CATEGORY_ID); - $criteria->addSelectColumn(ProductCategoryPeer::CREATED_AT); - $criteria->addSelectColumn(ProductCategoryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return ProductCategory - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ProductCategoryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ProductCategoryPeer::populateObjects(ProductCategoryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ProductCategoryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param ProductCategory $obj A ProductCategory object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = serialize(array((string) $obj->getProductId(), (string) $obj->getCategoryId())); - } // if key === null - ProductCategoryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A ProductCategory object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof ProductCategory) { - $key = serialize(array((string) $value->getProductId(), (string) $value->getCategoryId())); - } elseif (is_array($value) && count($value) === 2) { - // assume we've been passed a primary key - $key = serialize(array((string) $value[0], (string) $value[1])); - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or ProductCategory object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ProductCategoryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return ProductCategory Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ProductCategoryPeer::$instances[$key])) { - return ProductCategoryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ProductCategoryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ProductCategoryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to product_category - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (int) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ProductCategoryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ProductCategoryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (ProductCategory object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ProductCategoryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ProductCategoryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ProductCategory objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ProductCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - } - - ProductCategoryPeer::addSelectColumns($criteria); - $startcol = ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ProductCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ProductCategory) to $obj2 (Product) - $obj2->addProductCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ProductCategory objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ProductCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - } - - ProductCategoryPeer::addSelectColumns($criteria); - $startcol = ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ProductCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ProductCategory) to $obj2 (Category) - $obj2->addProductCategory($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ProductCategory objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ProductCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - } - - ProductCategoryPeer::addSelectColumns($criteria); - $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ProductCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ProductCategory) to the collection in $obj2 (Product) - $obj2->addProductCategory($obj1); - } // if joined row not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (ProductCategory) to the collection in $obj3 (Category) - $obj3->addProductCategory($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductCategoryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ProductCategory objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ProductCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - } - - ProductCategoryPeer::addSelectColumns($criteria); - $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ProductCategoryPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ProductCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ProductCategory) to the collection in $obj2 (Category) - $obj2->addProductCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of ProductCategory objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ProductCategory objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - } - - ProductCategoryPeer::addSelectColumns($criteria); - $startcol2 = ProductCategoryPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ProductCategoryPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductCategoryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductCategoryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ProductCategoryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (ProductCategory) to the collection in $obj2 (Product) - $obj2->addProductCategory($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ProductCategoryPeer::DATABASE_NAME)->getTable(ProductCategoryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseProductCategoryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseProductCategoryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ProductCategoryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ProductCategoryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ProductCategory or Criteria object. - * - * @param mixed $values Criteria or ProductCategory object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ProductCategory object - } - - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a ProductCategory or Criteria object. - * - * @param mixed $values Criteria or ProductCategory object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ProductCategoryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ProductCategoryPeer::PRODUCT_ID); - $value = $criteria->remove(ProductCategoryPeer::PRODUCT_ID); - if ($value) { - $selectCriteria->add(ProductCategoryPeer::PRODUCT_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ProductCategoryPeer::CATEGORY_ID); - $value = $criteria->remove(ProductCategoryPeer::CATEGORY_ID); - if ($value) { - $selectCriteria->add(ProductCategoryPeer::CATEGORY_ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ProductCategoryPeer::TABLE_NAME); - } - - } else { // $values is ProductCategory object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the product_category table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ProductCategoryPeer::TABLE_NAME, $con, ProductCategoryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ProductCategoryPeer::clearInstancePool(); - ProductCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ProductCategory or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ProductCategory object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ProductCategoryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ProductCategory) { // it's a model object - // invalidate the cache for this single object - ProductCategoryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(ProductCategoryPeer::PRODUCT_ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ProductCategoryPeer::CATEGORY_ID, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ProductCategoryPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ProductCategoryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ProductCategoryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ProductCategory object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param ProductCategory $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ProductCategoryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ProductCategoryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ProductCategoryPeer::DATABASE_NAME, ProductCategoryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $product_id - * @param int $category_id - * @param PropelPDO $con - * @return ProductCategory - */ - public static function retrieveByPK($product_id, $category_id, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $product_id, (string) $category_id)); - if (null !== ($obj = ProductCategoryPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ProductCategoryPeer::DATABASE_NAME); - $criteria->add(ProductCategoryPeer::PRODUCT_ID, $product_id); - $criteria->add(ProductCategoryPeer::CATEGORY_ID, $category_id); - $v = ProductCategoryPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseProductCategoryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseProductCategoryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php b/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php deleted file mode 100755 index 30a1d64d7..000000000 --- a/core/lib/Thelia/Model/om/BaseProductCategoryQuery.php +++ /dev/null @@ -1,660 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34), $con); - * - * - * @param array $key Primary key to use for the query - A Primary key composition: [$product_id, $category_id] - * @param PropelPDO $con an optional connection object - * - * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ProductCategoryPeer::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ProductCategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ProductCategory A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `product_id`, `category_id`, `created_at`, `updated_at` FROM `product_category` WHERE `product_id` = :p0 AND `category_id` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new ProductCategory(); - $obj->hydrate($row); - ProductCategoryPeer::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return ProductCategory|ProductCategory[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|ProductCategory[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $key[1], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(ProductCategoryPeer::PRODUCT_ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ProductCategoryPeer::CATEGORY_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ProductCategoryPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductCategoryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ProductCategoryPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Exclude object from result - * - * @param ProductCategory $productCategory Object to remove from the list of results - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function prune($productCategory = null) - { - if ($productCategory) { - $this->addCond('pruneCond0', $this->getAliasedColName(ProductCategoryPeer::PRODUCT_ID), $productCategory->getProductId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ProductCategoryPeer::CATEGORY_ID), $productCategory->getCategoryId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ProductCategoryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ProductCategoryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ProductCategoryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ProductCategoryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ProductCategoryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ProductCategoryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ProductCategoryPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseProductI18n.php b/core/lib/Thelia/Model/om/BaseProductI18n.php deleted file mode 100755 index d88cdd9c2..000000000 --- a/core/lib/Thelia/Model/om/BaseProductI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseProductI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ProductI18nPeer::ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ProductI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ProductI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ProductI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ProductI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ProductI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ProductI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ProductI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ProductI18n 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(ProductI18nPeer::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 = ProductI18nPeer::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(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ProductI18nQuery::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(ProductI18nPeer::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); - ProductI18nPeer::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(ProductI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ProductI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ProductI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ProductI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ProductI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ProductI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `product_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $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 = ProductI18nPeer::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 = ProductI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ProductI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ProductI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ProductI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - 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 = ProductI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ProductI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ProductI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ProductI18nPeer::ID)) $criteria->add(ProductI18nPeer::ID, $this->id); - if ($this->isColumnModified(ProductI18nPeer::LOCALE)) $criteria->add(ProductI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ProductI18nPeer::TITLE)) $criteria->add(ProductI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ProductI18nPeer::DESCRIPTION)) $criteria->add(ProductI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ProductI18nPeer::CHAPO)) $criteria->add(ProductI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ProductI18nPeer::POSTSCRIPTUM)) $criteria->add(ProductI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ProductI18nPeer::DATABASE_NAME); - $criteria->add(ProductI18nPeer::ID, $this->id); - $criteria->add(ProductI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ProductI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ProductI18n 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 ProductI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ProductI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return ProductI18n 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->addProductI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->addProductI18ns($this); - */ - } - - return $this->aProduct; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aProduct = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ProductI18nPeer::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/BaseProductI18nPeer.php b/core/lib/Thelia/Model/om/BaseProductI18nPeer.php deleted file mode 100755 index 5d16d3204..000000000 --- a/core/lib/Thelia/Model/om/BaseProductI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ProductI18nPeer::ID, ProductI18nPeer::LOCALE, ProductI18nPeer::TITLE, ProductI18nPeer::DESCRIPTION, ProductI18nPeer::CHAPO, ProductI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ProductI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ProductI18nPeer::ID => 0, ProductI18nPeer::LOCALE => 1, ProductI18nPeer::TITLE => 2, ProductI18nPeer::DESCRIPTION => 3, ProductI18nPeer::CHAPO => 4, ProductI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ProductI18nPeer::getFieldNames($toType); - $key = isset(ProductI18nPeer::$fieldKeys[$fromType][$name]) ? ProductI18nPeer::$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(ProductI18nPeer::$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, ProductI18nPeer::$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 ProductI18nPeer::$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. ProductI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ProductI18nPeer::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(ProductI18nPeer::ID); - $criteria->addSelectColumn(ProductI18nPeer::LOCALE); - $criteria->addSelectColumn(ProductI18nPeer::TITLE); - $criteria->addSelectColumn(ProductI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ProductI18nPeer::CHAPO); - $criteria->addSelectColumn(ProductI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ProductI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ProductI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ProductI18nPeer::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 ProductI18n - * @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 = ProductI18nPeer::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 ProductI18nPeer::populateObjects(ProductI18nPeer::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 directly (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(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ProductI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ProductI18nPeer::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 ProductI18n $obj A ProductI18n 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->getLocale())); - } // if key === null - ProductI18nPeer::$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 ProductI18n 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 ProductI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ProductI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ProductI18nPeer::$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 ProductI18n 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(ProductI18nPeer::$instances[$key])) { - return ProductI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ProductI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ProductI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to product_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ProductI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ProductI18nPeer::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; - ProductI18nPeer::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 (ProductI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ProductI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ProductI18nPeer::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 + ProductI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ProductI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ProductI18nPeer::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(ProductI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductI18nPeer::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 ProductI18n 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 ProductI18n 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(ProductI18nPeer::DATABASE_NAME); - } - - ProductI18nPeer::addSelectColumns($criteria); - $startcol = ProductI18nPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ProductI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductI18nPeer::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 (ProductI18n) to $obj2 (Product) - $obj2->addProductI18n($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(ProductI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductI18nPeer::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 ProductI18n 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 ProductI18n 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(ProductI18nPeer::DATABASE_NAME); - } - - ProductI18nPeer::addSelectColumns($criteria); - $startcol2 = ProductI18nPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ProductI18nPeer::ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ProductI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductI18nPeer::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 (ProductI18n) to the collection in $obj2 (Product) - $obj2->addProductI18n($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(ProductI18nPeer::DATABASE_NAME)->getTable(ProductI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseProductI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseProductI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ProductI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ProductI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ProductI18n or Criteria object. - * - * @param mixed $values Criteria or ProductI18n 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(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ProductI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ProductI18nPeer::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 ProductI18n or Criteria object. - * - * @param mixed $values Criteria or ProductI18n 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(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ProductI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ProductI18nPeer::ID); - $value = $criteria->remove(ProductI18nPeer::ID); - if ($value) { - $selectCriteria->add(ProductI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ProductI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ProductI18nPeer::LOCALE); - $value = $criteria->remove(ProductI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ProductI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ProductI18nPeer::TABLE_NAME); - } - - } else { // $values is ProductI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ProductI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the product_i18n 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(ProductI18nPeer::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(ProductI18nPeer::TABLE_NAME, $con, ProductI18nPeer::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). - ProductI18nPeer::clearInstancePool(); - ProductI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ProductI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ProductI18n 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(ProductI18nPeer::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. - ProductI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ProductI18n) { // it's a model object - // invalidate the cache for this single object - ProductI18nPeer::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(ProductI18nPeer::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(ProductI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ProductI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ProductI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ProductI18nPeer::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); - ProductI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ProductI18n 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 ProductI18n $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(ProductI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ProductI18nPeer::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(ProductI18nPeer::DATABASE_NAME, ProductI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ProductI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ProductI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ProductI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ProductI18nPeer::DATABASE_NAME); - $criteria->add(ProductI18nPeer::ID, $id); - $criteria->add(ProductI18nPeer::LOCALE, $locale); - $v = ProductI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseProductI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseProductI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php b/core/lib/Thelia/Model/om/BaseProductI18nQuery.php deleted file mode 100755 index 02dc6e1fd..000000000 --- a/core/lib/Thelia/Model/om/BaseProductI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ProductI18n|ProductI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ProductI18nPeer::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(ProductI18nPeer::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 ProductI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `product_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ProductI18n(); - $obj->hydrate($row); - ProductI18nPeer::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 ProductI18n|ProductI18n[]|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|ProductI18n[]|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 ProductI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ProductI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ProductI18nPeer::LOCALE, $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 ProductI18nQuery 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(ProductI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ProductI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 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 ProductI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ProductI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ProductI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ProductI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductI18nPeer::POSTSCRIPTUM, $postscriptum, $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 ProductI18nQuery 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(ProductI18nPeer::ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ProductI18nPeer::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 ProductI18nQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Exclude object from result - * - * @param ProductI18n $productI18n Object to remove from the list of results - * - * @return ProductI18nQuery The current query, for fluid interface - */ - public function prune($productI18n = null) - { - if ($productI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ProductI18nPeer::ID), $productI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ProductI18nPeer::LOCALE), $productI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseProductPeer.php b/core/lib/Thelia/Model/om/BaseProductPeer.php deleted file mode 100755 index 599bfc672..000000000 --- a/core/lib/Thelia/Model/om/BaseProductPeer.php +++ /dev/null @@ -1,1174 +0,0 @@ - array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', '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::QUANTITY, 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', 'QUANTITY', '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', 'quantity', '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. ProductPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'Ref' => 2, 'Price' => 3, 'Price2' => 4, 'Ecotax' => 5, 'Newness' => 6, 'Promo' => 7, 'Quantity' => 8, 'Visible' => 9, 'Weight' => 10, 'Position' => 11, 'CreatedAt' => 12, 'UpdatedAt' => 13, '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, 'quantity' => 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::QUANTITY => 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, 'QUANTITY' => 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, 'quantity' => 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 = ProductPeer::getFieldNames($toType); - $key = isset(ProductPeer::$fieldKeys[$fromType][$name]) ? ProductPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ProductPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ProductPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ProductPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ProductPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ProductPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ProductPeer::ID); - $criteria->addSelectColumn(ProductPeer::TAX_RULE_ID); - $criteria->addSelectColumn(ProductPeer::REF); - $criteria->addSelectColumn(ProductPeer::PRICE); - $criteria->addSelectColumn(ProductPeer::PRICE2); - $criteria->addSelectColumn(ProductPeer::ECOTAX); - $criteria->addSelectColumn(ProductPeer::NEWNESS); - $criteria->addSelectColumn(ProductPeer::PROMO); - $criteria->addSelectColumn(ProductPeer::QUANTITY); - $criteria->addSelectColumn(ProductPeer::VISIBLE); - $criteria->addSelectColumn(ProductPeer::WEIGHT); - $criteria->addSelectColumn(ProductPeer::POSITION); - $criteria->addSelectColumn(ProductPeer::CREATED_AT); - $criteria->addSelectColumn(ProductPeer::UPDATED_AT); - $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'); - $criteria->addSelectColumn($alias . '.ref'); - $criteria->addSelectColumn($alias . '.price'); - $criteria->addSelectColumn($alias . '.price2'); - $criteria->addSelectColumn($alias . '.ecotax'); - $criteria->addSelectColumn($alias . '.newness'); - $criteria->addSelectColumn($alias . '.promo'); - $criteria->addSelectColumn($alias . '.quantity'); - $criteria->addSelectColumn($alias . '.visible'); - $criteria->addSelectColumn($alias . '.weight'); - $criteria->addSelectColumn($alias . '.position'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - $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(ProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ProductPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Product - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ProductPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ProductPeer::populateObjects(ProductPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ProductPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Product $obj A Product object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ProductPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Product object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Product) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Product object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ProductPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Product Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ProductPeer::$instances[$key])) { - return ProductPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ProductPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ProductPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to product - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ProductCategoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ProductCategoryPeer::clearInstancePool(); - // Invalidate objects in FeatureProdPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - FeatureProdPeer::clearInstancePool(); - // Invalidate objects in StockPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - StockPeer::clearInstancePool(); - // Invalidate objects in ContentAssocPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ContentAssocPeer::clearInstancePool(); - // Invalidate objects in ImagePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ImagePeer::clearInstancePool(); - // Invalidate objects in DocumentPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - DocumentPeer::clearInstancePool(); - // Invalidate objects in AccessoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AccessoryPeer::clearInstancePool(); - // Invalidate objects in AccessoryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AccessoryPeer::clearInstancePool(); - // Invalidate objects in RewritingPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - RewritingPeer::clearInstancePool(); - // 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(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ProductPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ProductPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ProductPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Product object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ProductPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ProductPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ProductPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related TaxRule table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinTaxRule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Product objects pre-filled with their TaxRule objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Product objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductPeer::DATABASE_NAME); - } - - ProductPeer::addSelectColumns($criteria); - $startcol = ProductPeer::NUM_HYDRATE_COLUMNS; - TaxRulePeer::addSelectColumns($criteria); - - $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ProductPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Product) to $obj2 (TaxRule) - $obj2->addProduct($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ProductPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ProductPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Product objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Product objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ProductPeer::DATABASE_NAME); - } - - ProductPeer::addSelectColumns($criteria); - $startcol2 = ProductPeer::NUM_HYDRATE_COLUMNS; - - TaxRulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ProductPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ProductPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ProductPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ProductPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ProductPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined TaxRule rows - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Product) to the collection in $obj2 (TaxRule) - $obj2->addProduct($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ProductPeer::DATABASE_NAME)->getTable(ProductPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseProductPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseProductPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ProductTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ProductPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Product or Criteria object. - * - * @param mixed $values Criteria or Product object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Product object - } - - if ($criteria->containsKey(ProductPeer::ID) && $criteria->keyContainsValue(ProductPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProductPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Product or Criteria object. - * - * @param mixed $values Criteria or Product object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ProductPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ProductPeer::ID); - $value = $criteria->remove(ProductPeer::ID); - if ($value) { - $selectCriteria->add(ProductPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ProductPeer::TABLE_NAME); - } - - } else { // $values is Product object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the product table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ProductPeer::TABLE_NAME, $con, ProductPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ProductPeer::clearInstancePool(); - ProductPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Product or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Product object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ProductPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Product) { // it's a model object - // invalidate the cache for this single object - ProductPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ProductPeer::DATABASE_NAME); - $criteria->add(ProductPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ProductPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ProductPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ProductPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Product object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Product $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ProductPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ProductPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ProductPeer::DATABASE_NAME, ProductPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Product - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ProductPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ProductPeer::DATABASE_NAME); - $criteria->add(ProductPeer::ID, $pk); - - $v = ProductPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Product[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ProductPeer::DATABASE_NAME); - $criteria->add(ProductPeer::ID, $pks, Criteria::IN); - $objs = ProductPeer::doSelect($criteria, $con); - } - - return $objs; - } - - // 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. -// -BaseProductPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseProductQuery.php b/core/lib/Thelia/Model/om/BaseProductQuery.php deleted file mode 100755 index 90ccbf69b..000000000 --- a/core/lib/Thelia/Model/om/BaseProductQuery.php +++ /dev/null @@ -1,2125 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Product|Product[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ProductPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Product A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Product A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `tax_rule_id`, `ref`, `price`, `price2`, `ecotax`, `newness`, `promo`, `quantity`, `visible`, `weight`, `position`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by` FROM `product` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Product(); - $obj->hydrate($row); - ProductPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Product|Product[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Product[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ProductPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ProductPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ProductPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ProductPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByTaxRuleId(array('max' => 12)); // WHERE tax_rule_id <= 12 - * - * - * @see filterByTaxRule() - * - * @param mixed $taxRuleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByTaxRuleId($taxRuleId = null, $comparison = null) - { - if (is_array($taxRuleId)) { - $useMinMax = false; - if (isset($taxRuleId['min'])) { - $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($taxRuleId['max'])) { - $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRuleId, $comparison); - } - - /** - * Filter the query on the ref column - * - * Example usage: - * - * $query->filterByRef('fooValue'); // WHERE ref = 'fooValue' - * $query->filterByRef('%fooValue%'); // WHERE ref LIKE '%fooValue%' - * - * - * @param string $ref The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByRef($ref = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($ref)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $ref)) { - $ref = str_replace('*', '%', $ref); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ProductPeer::REF, $ref, $comparison); - } - - /** - * Filter the query on the price column - * - * Example usage: - * - * $query->filterByPrice(1234); // WHERE price = 1234 - * $query->filterByPrice(array(12, 34)); // WHERE price IN (12, 34) - * $query->filterByPrice(array('min' => 12)); // WHERE price >= 12 - * $query->filterByPrice(array('max' => 12)); // WHERE price <= 12 - * - * - * @param mixed $price The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPrice($price = null, $comparison = null) - { - if (is_array($price)) { - $useMinMax = false; - if (isset($price['min'])) { - $this->addUsingAlias(ProductPeer::PRICE, $price['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($price['max'])) { - $this->addUsingAlias(ProductPeer::PRICE, $price['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::PRICE, $price, $comparison); - } - - /** - * Filter the query on the price2 column - * - * Example usage: - * - * $query->filterByPrice2(1234); // WHERE price2 = 1234 - * $query->filterByPrice2(array(12, 34)); // WHERE price2 IN (12, 34) - * $query->filterByPrice2(array('min' => 12)); // WHERE price2 >= 12 - * $query->filterByPrice2(array('max' => 12)); // WHERE price2 <= 12 - * - * - * @param mixed $price2 The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPrice2($price2 = null, $comparison = null) - { - if (is_array($price2)) { - $useMinMax = false; - if (isset($price2['min'])) { - $this->addUsingAlias(ProductPeer::PRICE2, $price2['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($price2['max'])) { - $this->addUsingAlias(ProductPeer::PRICE2, $price2['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::PRICE2, $price2, $comparison); - } - - /** - * Filter the query on the ecotax column - * - * Example usage: - * - * $query->filterByEcotax(1234); // WHERE ecotax = 1234 - * $query->filterByEcotax(array(12, 34)); // WHERE ecotax IN (12, 34) - * $query->filterByEcotax(array('min' => 12)); // WHERE ecotax >= 12 - * $query->filterByEcotax(array('max' => 12)); // WHERE ecotax <= 12 - * - * - * @param mixed $ecotax The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByEcotax($ecotax = null, $comparison = null) - { - if (is_array($ecotax)) { - $useMinMax = false; - if (isset($ecotax['min'])) { - $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($ecotax['max'])) { - $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::ECOTAX, $ecotax, $comparison); - } - - /** - * Filter the query on the newness column - * - * Example usage: - * - * $query->filterByNewness(1234); // WHERE newness = 1234 - * $query->filterByNewness(array(12, 34)); // WHERE newness IN (12, 34) - * $query->filterByNewness(array('min' => 12)); // WHERE newness >= 12 - * $query->filterByNewness(array('max' => 12)); // WHERE newness <= 12 - * - * - * @param mixed $newness The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByNewness($newness = null, $comparison = null) - { - if (is_array($newness)) { - $useMinMax = false; - if (isset($newness['min'])) { - $this->addUsingAlias(ProductPeer::NEWNESS, $newness['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($newness['max'])) { - $this->addUsingAlias(ProductPeer::NEWNESS, $newness['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::NEWNESS, $newness, $comparison); - } - - /** - * Filter the query on the promo column - * - * Example usage: - * - * $query->filterByPromo(1234); // WHERE promo = 1234 - * $query->filterByPromo(array(12, 34)); // WHERE promo IN (12, 34) - * $query->filterByPromo(array('min' => 12)); // WHERE promo >= 12 - * $query->filterByPromo(array('max' => 12)); // WHERE promo <= 12 - * - * - * @param mixed $promo The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPromo($promo = null, $comparison = null) - { - if (is_array($promo)) { - $useMinMax = false; - if (isset($promo['min'])) { - $this->addUsingAlias(ProductPeer::PROMO, $promo['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($promo['max'])) { - $this->addUsingAlias(ProductPeer::PROMO, $promo['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::PROMO, $promo, $comparison); - } - - /** - * Filter the query on the quantity column - * - * Example usage: - * - * $query->filterByQuantity(1234); // WHERE quantity = 1234 - * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) - * $query->filterByQuantity(array('min' => 12)); // WHERE quantity >= 12 - * $query->filterByQuantity(array('max' => 12)); // WHERE quantity <= 12 - * - * - * @param mixed $quantity The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByQuantity($quantity = null, $comparison = null) - { - if (is_array($quantity)) { - $useMinMax = false; - if (isset($quantity['min'])) { - $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($quantity['max'])) { - $this->addUsingAlias(ProductPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::QUANTITY, $quantity, $comparison); - } - - /** - * Filter the query on the visible column - * - * Example usage: - * - * $query->filterByVisible(1234); // WHERE visible = 1234 - * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 - * $query->filterByVisible(array('max' => 12)); // WHERE visible <= 12 - * - * - * @param mixed $visible The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByVisible($visible = null, $comparison = null) - { - if (is_array($visible)) { - $useMinMax = false; - if (isset($visible['min'])) { - $this->addUsingAlias(ProductPeer::VISIBLE, $visible['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($visible['max'])) { - $this->addUsingAlias(ProductPeer::VISIBLE, $visible['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::VISIBLE, $visible, $comparison); - } - - /** - * Filter the query on the weight column - * - * Example usage: - * - * $query->filterByWeight(1234); // WHERE weight = 1234 - * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) - * $query->filterByWeight(array('min' => 12)); // WHERE weight >= 12 - * $query->filterByWeight(array('max' => 12)); // WHERE weight <= 12 - * - * - * @param mixed $weight The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByWeight($weight = null, $comparison = null) - { - if (is_array($weight)) { - $useMinMax = false; - if (isset($weight['min'])) { - $this->addUsingAlias(ProductPeer::WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($weight['max'])) { - $this->addUsingAlias(ProductPeer::WEIGHT, $weight['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::WEIGHT, $weight, $comparison); - } - - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position >= 12 - * $query->filterByPosition(array('max' => 12)); // WHERE position <= 12 - * - * - * @param mixed $position The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(ProductPeer::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(ProductPeer::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::POSITION, $position, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query 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 - * $query->filterByVersion(array('max' => 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 - * - * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRule($taxRule, $comparison = null) - { - if ($taxRule instanceof TaxRule) { - return $this - ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->getId(), $comparison); - } elseif ($taxRule instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ProductPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRule'); - } - - return $this; - } - - /** - * Use the TaxRule relation TaxRule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery'); - } - - /** - * Filter the query by a related ProductCategory object - * - * @param ProductCategory|PropelObjectCollection $productCategory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProductCategory($productCategory, $comparison = null) - { - if ($productCategory instanceof ProductCategory) { - return $this - ->addUsingAlias(ProductPeer::ID, $productCategory->getProductId(), $comparison); - } elseif ($productCategory instanceof PropelObjectCollection) { - return $this - ->useProductCategoryQuery() - ->filterByPrimaryKeys($productCategory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProductCategory() only accepts arguments of type ProductCategory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductCategory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinProductCategory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductCategory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductCategory'); - } - - return $this; - } - - /** - * Use the ProductCategory relation ProductCategory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductCategoryQuery A secondary query class using the current class as primary query - */ - public function useProductCategoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProductCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductCategory', '\Thelia\Model\ProductCategoryQuery'); - } - - /** - * Filter the query by a related FeatureProd object - * - * @param FeatureProd|PropelObjectCollection $featureProd the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFeatureProd($featureProd, $comparison = null) - { - if ($featureProd instanceof FeatureProd) { - return $this - ->addUsingAlias(ProductPeer::ID, $featureProd->getProductId(), $comparison); - } elseif ($featureProd instanceof PropelObjectCollection) { - return $this - ->useFeatureProdQuery() - ->filterByPrimaryKeys($featureProd->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByFeatureProd() only accepts arguments of type FeatureProd or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the FeatureProd relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinFeatureProd($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('FeatureProd'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'FeatureProd'); - } - - return $this; - } - - /** - * Use the FeatureProd relation FeatureProd object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FeatureProdQuery A secondary query class using the current class as primary query - */ - public function useFeatureProdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinFeatureProd($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'FeatureProd', '\Thelia\Model\FeatureProdQuery'); - } - - /** - * Filter the query by a related Stock object - * - * @param Stock|PropelObjectCollection $stock the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByStock($stock, $comparison = null) - { - if ($stock instanceof Stock) { - return $this - ->addUsingAlias(ProductPeer::ID, $stock->getProductId(), $comparison); - } elseif ($stock instanceof PropelObjectCollection) { - return $this - ->useStockQuery() - ->filterByPrimaryKeys($stock->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByStock() only accepts arguments of type Stock or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Stock relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinStock($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Stock'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Stock'); - } - - return $this; - } - - /** - * Use the Stock relation Stock object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\StockQuery A secondary query class using the current class as primary query - */ - public function useStockQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinStock($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Stock', '\Thelia\Model\StockQuery'); - } - - /** - * Filter the query by a related ContentAssoc object - * - * @param ContentAssoc|PropelObjectCollection $contentAssoc the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContentAssoc($contentAssoc, $comparison = null) - { - if ($contentAssoc instanceof ContentAssoc) { - return $this - ->addUsingAlias(ProductPeer::ID, $contentAssoc->getProductId(), $comparison); - } elseif ($contentAssoc instanceof PropelObjectCollection) { - return $this - ->useContentAssocQuery() - ->filterByPrimaryKeys($contentAssoc->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByContentAssoc() only accepts arguments of type ContentAssoc or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ContentAssoc relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinContentAssoc($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ContentAssoc'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ContentAssoc'); - } - - return $this; - } - - /** - * Use the ContentAssoc relation ContentAssoc object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentAssocQuery A secondary query class using the current class as primary query - */ - public function useContentAssocQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContentAssoc($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ContentAssoc', '\Thelia\Model\ContentAssocQuery'); - } - - /** - * Filter the query by a related Image object - * - * @param Image|PropelObjectCollection $image the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByImage($image, $comparison = null) - { - if ($image instanceof Image) { - return $this - ->addUsingAlias(ProductPeer::ID, $image->getProductId(), $comparison); - } elseif ($image instanceof PropelObjectCollection) { - return $this - ->useImageQuery() - ->filterByPrimaryKeys($image->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByImage() only accepts arguments of type Image or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Image relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinImage($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Image'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Image'); - } - - return $this; - } - - /** - * Use the Image relation Image object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ImageQuery A secondary query class using the current class as primary query - */ - public function useImageQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinImage($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Image', '\Thelia\Model\ImageQuery'); - } - - /** - * Filter the query by a related Document object - * - * @param Document|PropelObjectCollection $document the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByDocument($document, $comparison = null) - { - if ($document instanceof Document) { - return $this - ->addUsingAlias(ProductPeer::ID, $document->getProductId(), $comparison); - } elseif ($document instanceof PropelObjectCollection) { - return $this - ->useDocumentQuery() - ->filterByPrimaryKeys($document->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByDocument() only accepts arguments of type Document or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Document relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinDocument($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Document'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Document'); - } - - return $this; - } - - /** - * Use the Document relation Document object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\DocumentQuery A secondary query class using the current class as primary query - */ - public function useDocumentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinDocument($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Document', '\Thelia\Model\DocumentQuery'); - } - - /** - * Filter the query by a related Accessory object - * - * @param Accessory|PropelObjectCollection $accessory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAccessoryRelatedByProductId($accessory, $comparison = null) - { - if ($accessory instanceof Accessory) { - return $this - ->addUsingAlias(ProductPeer::ID, $accessory->getProductId(), $comparison); - } elseif ($accessory instanceof PropelObjectCollection) { - return $this - ->useAccessoryRelatedByProductIdQuery() - ->filterByPrimaryKeys($accessory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAccessoryRelatedByProductId() only accepts arguments of type Accessory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AccessoryRelatedByProductId relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinAccessoryRelatedByProductId($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AccessoryRelatedByProductId'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AccessoryRelatedByProductId'); - } - - return $this; - } - - /** - * Use the AccessoryRelatedByProductId relation Accessory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query - */ - public function useAccessoryRelatedByProductIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAccessoryRelatedByProductId($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByProductId', '\Thelia\Model\AccessoryQuery'); - } - - /** - * Filter the query by a related Accessory object - * - * @param Accessory|PropelObjectCollection $accessory the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByAccessoryRelatedByAccessory($accessory, $comparison = null) - { - if ($accessory instanceof Accessory) { - return $this - ->addUsingAlias(ProductPeer::ID, $accessory->getAccessory(), $comparison); - } elseif ($accessory instanceof PropelObjectCollection) { - return $this - ->useAccessoryRelatedByAccessoryQuery() - ->filterByPrimaryKeys($accessory->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAccessoryRelatedByAccessory() only accepts arguments of type Accessory or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the AccessoryRelatedByAccessory relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinAccessoryRelatedByAccessory($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AccessoryRelatedByAccessory'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AccessoryRelatedByAccessory'); - } - - return $this; - } - - /** - * Use the AccessoryRelatedByAccessory relation Accessory object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AccessoryQuery A secondary query class using the current class as primary query - */ - public function useAccessoryRelatedByAccessoryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAccessoryRelatedByAccessory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AccessoryRelatedByAccessory', '\Thelia\Model\AccessoryQuery'); - } - - /** - * Filter the query by a related Rewriting object - * - * @param Rewriting|PropelObjectCollection $rewriting the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByRewriting($rewriting, $comparison = null) - { - if ($rewriting instanceof Rewriting) { - return $this - ->addUsingAlias(ProductPeer::ID, $rewriting->getProductId(), $comparison); - } elseif ($rewriting instanceof PropelObjectCollection) { - return $this - ->useRewritingQuery() - ->filterByPrimaryKeys($rewriting->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByRewriting() only accepts arguments of type Rewriting or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Rewriting relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinRewriting($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Rewriting'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Rewriting'); - } - - return $this; - } - - /** - * Use the Rewriting relation Rewriting object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\RewritingQuery A secondary query class using the current class as primary query - */ - public function useRewritingQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinRewriting($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Rewriting', '\Thelia\Model\RewritingQuery'); - } - - /** - * Filter the query by a related ProductI18n object - * - * @param ProductI18n|PropelObjectCollection $productI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProductI18n($productI18n, $comparison = null) - { - if ($productI18n instanceof ProductI18n) { - return $this - ->addUsingAlias(ProductPeer::ID, $productI18n->getId(), $comparison); - } elseif ($productI18n instanceof PropelObjectCollection) { - return $this - ->useProductI18nQuery() - ->filterByPrimaryKeys($productI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProductI18n() only accepts arguments of type ProductI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ProductI18n 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 joinProductI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ProductI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ProductI18n'); - } - - return $this; - } - - /** - * Use the ProductI18n relation ProductI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductI18nQuery A secondary query class using the current class as primary query - */ - public function useProductI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinProductI18n($relationAlias, $joinType) - ->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'); - } - - /** - * Filter the query by a related Category object - * using the product_category table as cross reference - * - * @param Category $category 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 - */ - public function filterByCategory($category, $comparison = Criteria::EQUAL) - { - return $this - ->useProductCategoryQuery() - ->filterByCategory($category, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Product object - * using the accessory table as cross reference - * - * @param Product $product 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 - */ - public function filterByProductRelatedByAccessory($product, $comparison = Criteria::EQUAL) - { - return $this - ->useAccessoryRelatedByProductIdQuery() - ->filterByProductRelatedByAccessory($product, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Product object - * using the accessory table as cross reference - * - * @param Product $product 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 - */ - public function filterByProductRelatedByProductId($product, $comparison = Criteria::EQUAL) - { - return $this - ->useAccessoryRelatedByAccessoryQuery() - ->filterByProductRelatedByProductId($product, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Product $product Object to remove from the list of results - * - * @return ProductQuery The current query, for fluid interface - */ - public function prune($product = null) - { - if ($product) { - $this->addUsingAlias(ProductPeer::ID, $product->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ProductQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ProductPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ProductQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ProductPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ProductQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ProductPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ProductQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ProductPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ProductQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ProductPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ProductQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ProductPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; - - return $this - ->joinProductI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ProductQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ProductI18n'); - $this->with['ProductI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ProductI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ProductI18n', 'Thelia\Model\ProductI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseProductVersion.php b/core/lib/Thelia/Model/om/BaseProductVersion.php deleted file mode 100755 index 341966473..000000000 --- a/core/lib/Thelia/Model/om/BaseProductVersion.php +++ /dev/null @@ -1,1914 +0,0 @@ -newness = 0; - $this->promo = 0; - $this->quantity = 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 [quantity] column value. - * - * @return int - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * Get the [visible] column value. - * - * @return int - */ - public function getVisible() - { - return $this->visible; - } - - /** - * Get the [weight] column value. - * - * @return double - */ - public function getWeight() - { - return $this->weight; - } - - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->promo !== $v) { - $this->promo = $v; - $this->modifiedColumns[] = ProductVersionPeer::PROMO; - } - - - return $this; - } // setPromo() - - /** - * Set the value of [quantity] column. - * - * @param int $v new value - * @return ProductVersion The current object (for fluent API support) - */ - public function setQuantity($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->quantity !== $v) { - $this->quantity = $v; - $this->modifiedColumns[] = ProductVersionPeer::QUANTITY; - } - - - return $this; - } // setQuantity() - - /** - * 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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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 && is_numeric($v)) { - $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->quantity !== 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->quantity = ($row[$startcol + 8] !== null) ? (int) $row[$startcol + 8] : null; - $this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null; - $this->weight = ($row[$startcol + 10] !== null) ? (double) $row[$startcol + 10] : null; - $this->position = ($row[$startcol + 11] !== null) ? (int) $row[$startcol + 11] : null; - $this->created_at = ($row[$startcol + 12] !== null) ? (string) $row[$startcol + 12] : null; - $this->updated_at = ($row[$startcol + 13] !== null) ? (string) $row[$startcol + 13] : null; - $this->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(); - } - $this->postHydrate($row, $startcol, $rehydrate); - 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::QUANTITY)) { - $modifiedColumns[':p' . $index++] = '`quantity`'; - } - 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 '`quantity`': - $stmt->bindValue($identifier, $this->quantity, PDO::PARAM_INT); - break; - case '`visible`': - $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); - break; - case '`weight`': - $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); - break; - case '`position`': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - 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; - } - - $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->getQuantity(); - break; - case 9: - return $this->getVisible(); - break; - case 10: - return $this->getWeight(); - break; - case 11: - return $this->getPosition(); - break; - case 12: - return $this->getCreatedAt(); - break; - case 13: - return $this->getUpdatedAt(); - break; - 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->getQuantity(), - $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->setQuantity($value); - break; - case 9: - $this->setVisible($value); - break; - case 10: - $this->setWeight($value); - break; - case 11: - $this->setPosition($value); - break; - case 12: - $this->setCreatedAt($value); - break; - case 13: - $this->setUpdatedAt($value); - break; - 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->setQuantity($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]); - if (array_key_exists($keys[10], $arr)) $this->setWeight($arr[$keys[10]]); - if (array_key_exists($keys[11], $arr)) $this->setPosition($arr[$keys[11]]); - if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]); - if (array_key_exists($keys[13], $arr)) $this->setUpdatedAt($arr[$keys[13]]); - 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::QUANTITY)) $criteria->add(ProductVersionPeer::QUANTITY, $this->quantity); - 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->setQuantity($this->getQuantity()); - $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. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - 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->quantity = 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->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // 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 deleted file mode 100755 index 648e5696a..000000000 --- a/core/lib/Thelia/Model/om/BaseProductVersionPeer.php +++ /dev/null @@ -1,1071 +0,0 @@ - array ('Id', 'TaxRuleId', 'Ref', 'Price', 'Price2', 'Ecotax', 'Newness', 'Promo', 'Quantity', 'Visible', 'Weight', 'Position', 'CreatedAt', 'UpdatedAt', 'Version', 'VersionCreatedAt', 'VersionCreatedBy', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'ref', 'price', 'price2', 'ecotax', 'newness', 'promo', 'quantity', '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::QUANTITY, 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', 'QUANTITY', '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', 'quantity', '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, 'Quantity' => 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, 'quantity' => 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::QUANTITY => 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, 'QUANTITY' => 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, 'quantity' => 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::QUANTITY); - $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 . '.quantity'); - $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 directly (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($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ProductVersionPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - 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($row = 0, $colnum = 0) - { - 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 deleted file mode 100755 index 9d3e71a40..000000000 --- a/core/lib/Thelia/Model/om/BaseProductVersionQuery.php +++ /dev/null @@ -1,1085 +0,0 @@ -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`, `quantity`, `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 - * $query->filterById(array('max' => 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)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ProductVersionPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ProductVersionPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductVersionPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByTaxRuleId(array('max' => 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 - * $query->filterByPrice(array('max' => 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 - * $query->filterByPrice2(array('max' => 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 - * $query->filterByEcotax(array('max' => 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 - * $query->filterByNewness(array('max' => 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 - * $query->filterByPromo(array('max' => 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 quantity column - * - * Example usage: - * - * $query->filterByQuantity(1234); // WHERE quantity = 1234 - * $query->filterByQuantity(array(12, 34)); // WHERE quantity IN (12, 34) - * $query->filterByQuantity(array('min' => 12)); // WHERE quantity >= 12 - * $query->filterByQuantity(array('max' => 12)); // WHERE quantity <= 12 - * - * - * @param mixed $quantity The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ProductVersionQuery The current query, for fluid interface - */ - public function filterByQuantity($quantity = null, $comparison = null) - { - if (is_array($quantity)) { - $useMinMax = false; - if (isset($quantity['min'])) { - $this->addUsingAlias(ProductVersionPeer::QUANTITY, $quantity['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($quantity['max'])) { - $this->addUsingAlias(ProductVersionPeer::QUANTITY, $quantity['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductVersionPeer::QUANTITY, $quantity, $comparison); - } - - /** - * Filter the query on the visible column - * - * Example usage: - * - * $query->filterByVisible(1234); // WHERE visible = 1234 - * $query->filterByVisible(array(12, 34)); // WHERE visible IN (12, 34) - * $query->filterByVisible(array('min' => 12)); // WHERE visible >= 12 - * $query->filterByVisible(array('max' => 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 - * $query->filterByWeight(array('max' => 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 - * $query->filterByPosition(array('max' => 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 - * $query->filterByVersion(array('max' => 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)) { - $useMinMax = false; - if (isset($version['min'])) { - $this->addUsingAlias(ProductVersionPeer::VERSION, $version['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($version['max'])) { - $this->addUsingAlias(ProductVersionPeer::VERSION, $version['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ProductVersionPeer::VERSION, $version, $comparison); - } - - /** - * 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/core/lib/Thelia/Model/om/BaseResource.php b/core/lib/Thelia/Model/om/BaseResource.php deleted file mode 100755 index 9e9c26153..000000000 --- a/core/lib/Thelia/Model/om/BaseResource.php +++ /dev/null @@ -1,2090 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Resource The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ResourcePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return Resource The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = ResourcePeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Resource The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = ResourcePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Resource The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = ResourcePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = ResourcePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Resource object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = ResourcePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collGroupResources = null; - - $this->collResourceI18ns = null; - - $this->collGroups = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ResourceQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(ResourcePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(ResourcePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(ResourcePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - ResourcePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->groupsScheduledForDeletion !== null) { - if (!$this->groupsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($remotePk, $pk); - } - GroupResourceQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->groupsScheduledForDeletion = null; - } - - foreach ($this->getGroups() as $group) { - if ($group->isModified()) { - $group->save($con); - } - } - } elseif ($this->collGroups) { - foreach ($this->collGroups as $group) { - if ($group->isModified()) { - $group->save($con); - } - } - } - - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupResourcesScheduledForDeletion = null; - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->resourceI18nsScheduledForDeletion !== null) { - if (!$this->resourceI18nsScheduledForDeletion->isEmpty()) { - ResourceI18nQuery::create() - ->filterByPrimaryKeys($this->resourceI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->resourceI18nsScheduledForDeletion = null; - } - } - - if ($this->collResourceI18ns !== null) { - foreach ($this->collResourceI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = ResourcePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ResourcePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ResourcePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ResourcePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(ResourcePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `resource` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = ResourcePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collResourceI18ns !== null) { - foreach ($this->collResourceI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Resource'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Resource'][$this->getPrimaryKey()] = true; - $keys = ResourcePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collGroupResources) { - $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collResourceI18ns) { - $result['ResourceI18ns'] = $this->collResourceI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ResourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = ResourcePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - - if ($this->isColumnModified(ResourcePeer::ID)) $criteria->add(ResourcePeer::ID, $this->id); - if ($this->isColumnModified(ResourcePeer::CODE)) $criteria->add(ResourcePeer::CODE, $this->code); - if ($this->isColumnModified(ResourcePeer::CREATED_AT)) $criteria->add(ResourcePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(ResourcePeer::UPDATED_AT)) $criteria->add(ResourcePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - $criteria->add(ResourcePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Resource (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getGroupResources() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupResource($relObj->copy($deepCopy)); - } - } - - foreach ($this->getResourceI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addResourceI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Resource Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return ResourcePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ResourcePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('GroupResource' == $relationName) { - $this->initGroupResources(); - } - if ('ResourceI18n' == $relationName) { - $this->initResourceI18ns(); - } - } - - /** - * Clears out the collGroupResources collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Resource The current object (for fluent API support) - * @see addGroupResources() - */ - public function clearGroupResources() - { - $this->collGroupResources = null; // important to set this to null since that means it is uninitialized - $this->collGroupResourcesPartial = null; - - return $this; - } - - /** - * reset is the collGroupResources collection loaded partially - * - * @return void - */ - public function resetPartialGroupResources($v = true) - { - $this->collGroupResourcesPartial = $v; - } - - /** - * Initializes the collGroupResources collection. - * - * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupResources($overrideExisting = true) - { - if (null !== $this->collGroupResources && !$overrideExisting) { - return; - } - $this->collGroupResources = new PropelObjectCollection(); - $this->collGroupResources->setModel('GroupResource'); - } - - /** - * Gets an array of GroupResource objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Resource is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - * @throws PropelException - */ - public function getGroupResources($criteria = null, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - // return empty collection - $this->initGroupResources(); - } else { - $collGroupResources = GroupResourceQuery::create(null, $criteria) - ->filterByResource($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); - - foreach($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); - } - } - - $this->collGroupResourcesPartial = true; - } - - $collGroupResources->getInternalIterator()->rewind(); - return $collGroupResources; - } - - if($partial && $this->collGroupResources) { - foreach($this->collGroupResources as $obj) { - if($obj->isNew()) { - $collGroupResources[] = $obj; - } - } - } - - $this->collGroupResources = $collGroupResources; - $this->collGroupResourcesPartial = false; - } - } - - return $this->collGroupResources; - } - - /** - * Sets a collection of GroupResource objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $groupResources A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Resource The current object (for fluent API support) - */ - public function setGroupResources(PropelCollection $groupResources, PropelPDO $con = null) - { - $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - - $this->groupResourcesScheduledForDeletion = unserialize(serialize($groupResourcesToDelete)); - - foreach ($groupResourcesToDelete as $groupResourceRemoved) { - $groupResourceRemoved->setResource(null); - } - - $this->collGroupResources = null; - foreach ($groupResources as $groupResource) { - $this->addGroupResource($groupResource); - } - - $this->collGroupResources = $groupResources; - $this->collGroupResourcesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupResource objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related GroupResource objects. - * @throws PropelException - */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getGroupResources()); - } - $query = GroupResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); - } - - return count($this->collGroupResources); - } - - /** - * Method called to associate a GroupResource object to this object - * through the GroupResource foreign key attribute. - * - * @param GroupResource $l GroupResource - * @return Resource The current object (for fluent API support) - */ - public function addGroupResource(GroupResource $l) - { - if ($this->collGroupResources === null) { - $this->initGroupResources(); - $this->collGroupResourcesPartial = true; - } - if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupResource($l); - } - - return $this; - } - - /** - * @param GroupResource $groupResource The groupResource object to add. - */ - protected function doAddGroupResource($groupResource) - { - $this->collGroupResources[]= $groupResource; - $groupResource->setResource($this); - } - - /** - * @param GroupResource $groupResource The groupResource object to remove. - * @return Resource The current object (for fluent API support) - */ - public function removeGroupResource($groupResource) - { - if ($this->getGroupResources()->contains($groupResource)) { - $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); - if (null === $this->groupResourcesScheduledForDeletion) { - $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; - $this->groupResourcesScheduledForDeletion->clear(); - } - $this->groupResourcesScheduledForDeletion[]= clone $groupResource; - $groupResource->setResource(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Resource is new, it will return - * an empty collection; or if this Resource has previously - * been saved, it will retrieve related GroupResources from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Resource. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|GroupResource[] List of GroupResource objects - */ - public function getGroupResourcesJoinGroup($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = GroupResourceQuery::create(null, $criteria); - $query->joinWith('Group', $join_behavior); - - return $this->getGroupResources($query, $con); - } - - /** - * Clears out the collResourceI18ns 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 Resource The current object (for fluent API support) - * @see addResourceI18ns() - */ - public function clearResourceI18ns() - { - $this->collResourceI18ns = null; // important to set this to null since that means it is uninitialized - $this->collResourceI18nsPartial = null; - - return $this; - } - - /** - * reset is the collResourceI18ns collection loaded partially - * - * @return void - */ - public function resetPartialResourceI18ns($v = true) - { - $this->collResourceI18nsPartial = $v; - } - - /** - * Initializes the collResourceI18ns collection. - * - * By default this just sets the collResourceI18ns collection to an empty array (like clearcollResourceI18ns()); - * 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 initResourceI18ns($overrideExisting = true) - { - if (null !== $this->collResourceI18ns && !$overrideExisting) { - return; - } - $this->collResourceI18ns = new PropelObjectCollection(); - $this->collResourceI18ns->setModel('ResourceI18n'); - } - - /** - * Gets an array of ResourceI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Resource is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|ResourceI18n[] List of ResourceI18n objects - * @throws PropelException - */ - public function getResourceI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collResourceI18nsPartial && !$this->isNew(); - if (null === $this->collResourceI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collResourceI18ns) { - // return empty collection - $this->initResourceI18ns(); - } else { - $collResourceI18ns = ResourceI18nQuery::create(null, $criteria) - ->filterByResource($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collResourceI18nsPartial && count($collResourceI18ns)) { - $this->initResourceI18ns(false); - - foreach($collResourceI18ns as $obj) { - if (false == $this->collResourceI18ns->contains($obj)) { - $this->collResourceI18ns->append($obj); - } - } - - $this->collResourceI18nsPartial = true; - } - - $collResourceI18ns->getInternalIterator()->rewind(); - return $collResourceI18ns; - } - - if($partial && $this->collResourceI18ns) { - foreach($this->collResourceI18ns as $obj) { - if($obj->isNew()) { - $collResourceI18ns[] = $obj; - } - } - } - - $this->collResourceI18ns = $collResourceI18ns; - $this->collResourceI18nsPartial = false; - } - } - - return $this->collResourceI18ns; - } - - /** - * Sets a collection of ResourceI18n 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 $resourceI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Resource The current object (for fluent API support) - */ - public function setResourceI18ns(PropelCollection $resourceI18ns, PropelPDO $con = null) - { - $resourceI18nsToDelete = $this->getResourceI18ns(new Criteria(), $con)->diff($resourceI18ns); - - $this->resourceI18nsScheduledForDeletion = unserialize(serialize($resourceI18nsToDelete)); - - foreach ($resourceI18nsToDelete as $resourceI18nRemoved) { - $resourceI18nRemoved->setResource(null); - } - - $this->collResourceI18ns = null; - foreach ($resourceI18ns as $resourceI18n) { - $this->addResourceI18n($resourceI18n); - } - - $this->collResourceI18ns = $resourceI18ns; - $this->collResourceI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related ResourceI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related ResourceI18n objects. - * @throws PropelException - */ - public function countResourceI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collResourceI18nsPartial && !$this->isNew(); - if (null === $this->collResourceI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collResourceI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getResourceI18ns()); - } - $query = ResourceI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); - } - - return count($this->collResourceI18ns); - } - - /** - * Method called to associate a ResourceI18n object to this object - * through the ResourceI18n foreign key attribute. - * - * @param ResourceI18n $l ResourceI18n - * @return Resource The current object (for fluent API support) - */ - public function addResourceI18n(ResourceI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collResourceI18ns === null) { - $this->initResourceI18ns(); - $this->collResourceI18nsPartial = true; - } - if (!in_array($l, $this->collResourceI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddResourceI18n($l); - } - - return $this; - } - - /** - * @param ResourceI18n $resourceI18n The resourceI18n object to add. - */ - protected function doAddResourceI18n($resourceI18n) - { - $this->collResourceI18ns[]= $resourceI18n; - $resourceI18n->setResource($this); - } - - /** - * @param ResourceI18n $resourceI18n The resourceI18n object to remove. - * @return Resource The current object (for fluent API support) - */ - public function removeResourceI18n($resourceI18n) - { - if ($this->getResourceI18ns()->contains($resourceI18n)) { - $this->collResourceI18ns->remove($this->collResourceI18ns->search($resourceI18n)); - if (null === $this->resourceI18nsScheduledForDeletion) { - $this->resourceI18nsScheduledForDeletion = clone $this->collResourceI18ns; - $this->resourceI18nsScheduledForDeletion->clear(); - } - $this->resourceI18nsScheduledForDeletion[]= clone $resourceI18n; - $resourceI18n->setResource(null); - } - - return $this; - } - - /** - * Clears out the collGroups 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 Resource The current object (for fluent API support) - * @see addGroups() - */ - public function clearGroups() - { - $this->collGroups = null; // important to set this to null since that means it is uninitialized - $this->collGroupsPartial = null; - - return $this; - } - - /** - * Initializes the collGroups collection. - * - * By default this just sets the collGroups collection to an empty collection (like clearGroups()); - * 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. - * - * @return void - */ - public function initGroups() - { - $this->collGroups = new PropelObjectCollection(); - $this->collGroups->setModel('Group'); - } - - /** - * Gets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Resource is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param PropelPDO $con Optional connection object - * - * @return PropelObjectCollection|Group[] List of Group objects - */ - public function getGroups($criteria = null, PropelPDO $con = null) - { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { - // return empty collection - $this->initGroups(); - } else { - $collGroups = GroupQuery::create(null, $criteria) - ->filterByResource($this) - ->find($con); - if (null !== $criteria) { - return $collGroups; - } - $this->collGroups = $collGroups; - } - } - - return $this->collGroups; - } - - /** - * Sets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * 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 $groups A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Resource The current object (for fluent API support) - */ - public function setGroups(PropelCollection $groups, PropelPDO $con = null) - { - $this->clearGroups(); - $currentGroups = $this->getGroups(); - - $this->groupsScheduledForDeletion = $currentGroups->diff($groups); - - foreach ($groups as $group) { - if (!$currentGroups->contains($group)) { - $this->doAddGroup($group); - } - } - - $this->collGroups = $groups; - - return $this; - } - - /** - * Gets the number of Group objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param PropelPDO $con Optional connection object - * - * @return int the number of related Group objects - */ - public function countGroups($criteria = null, $distinct = false, PropelPDO $con = null) - { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { - return 0; - } else { - $query = GroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByResource($this) - ->count($con); - } - } else { - return count($this->collGroups); - } - } - - /** - * Associate a Group object to this object - * through the group_resource cross reference table. - * - * @param Group $group The GroupResource object to relate - * @return Resource The current object (for fluent API support) - */ - public function addGroup(Group $group) - { - if ($this->collGroups === null) { - $this->initGroups(); - } - if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated - $this->doAddGroup($group); - - $this->collGroups[]= $group; - } - - return $this; - } - - /** - * @param Group $group The group object to add. - */ - protected function doAddGroup($group) - { - $groupResource = new GroupResource(); - $groupResource->setGroup($group); - $this->addGroupResource($groupResource); - } - - /** - * Remove a Group object to this object - * through the group_resource cross reference table. - * - * @param Group $group The GroupResource object to relate - * @return Resource The current object (for fluent API support) - */ - public function removeGroup(Group $group) - { - if ($this->getGroups()->contains($group)) { - $this->collGroups->remove($this->collGroups->search($group)); - if (null === $this->groupsScheduledForDeletion) { - $this->groupsScheduledForDeletion = clone $this->collGroups; - $this->groupsScheduledForDeletion->clear(); - } - $this->groupsScheduledForDeletion[]= $group; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collGroupResources) { - foreach ($this->collGroupResources as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collResourceI18ns) { - foreach ($this->collResourceI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroups) { - foreach ($this->collGroups as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collGroupResources instanceof PropelCollection) { - $this->collGroupResources->clearIterator(); - } - $this->collGroupResources = null; - if ($this->collResourceI18ns instanceof PropelCollection) { - $this->collResourceI18ns->clearIterator(); - } - $this->collResourceI18ns = null; - if ($this->collGroups instanceof PropelCollection) { - $this->collGroups->clearIterator(); - } - $this->collGroups = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ResourcePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Resource The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = ResourcePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Resource The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return ResourceI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collResourceI18ns) { - foreach ($this->collResourceI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ResourceI18n(); - $translation->setLocale($locale); - } else { - $translation = ResourceI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addResourceI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Resource The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - ResourceI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collResourceI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collResourceI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return ResourceI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseResourceI18n.php b/core/lib/Thelia/Model/om/BaseResourceI18n.php deleted file mode 100755 index 74506641d..000000000 --- a/core/lib/Thelia/Model/om/BaseResourceI18n.php +++ /dev/null @@ -1,1187 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseResourceI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = ResourceI18nPeer::ID; - } - - if ($this->aResource !== null && $this->aResource->getId() !== $v) { - $this->aResource = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = ResourceI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = ResourceI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = ResourceI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = ResourceI18nPeer::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return ResourceI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = ResourceI18nPeer::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->chapo = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->postscriptum = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = ResourceI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating ResourceI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aResource !== null && $this->id !== $this->aResource->getId()) { - $this->aResource = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::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 = ResourceI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aResource = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = ResourceI18nQuery::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(ResourceI18nPeer::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); - ResourceI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aResource !== null) { - if ($this->aResource->isModified() || $this->aResource->isNew()) { - $affectedRows += $this->aResource->save($con); - } - $this->setResource($this->aResource); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(ResourceI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(ResourceI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(ResourceI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(ResourceI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(ResourceI18nPeer::CHAPO)) { - $modifiedColumns[':p' . $index++] = '`chapo`'; - } - if ($this->isColumnModified(ResourceI18nPeer::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = '`postscriptum`'; - } - - $sql = sprintf( - 'INSERT INTO `resource_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`chapo`': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case '`postscriptum`': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aResource !== null) { - if (!$this->aResource->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aResource->getValidationFailures()); - } - } - - - if (($retval = ResourceI18nPeer::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 = ResourceI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - 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['ResourceI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['ResourceI18n'][serialize($this->getPrimaryKey())] = true; - $keys = ResourceI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - if ($includeForeignObjects) { - if (null !== $this->aResource) { - $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = ResourceI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($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 = ResourceI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(ResourceI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(ResourceI18nPeer::ID)) $criteria->add(ResourceI18nPeer::ID, $this->id); - if ($this->isColumnModified(ResourceI18nPeer::LOCALE)) $criteria->add(ResourceI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(ResourceI18nPeer::TITLE)) $criteria->add(ResourceI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(ResourceI18nPeer::DESCRIPTION)) $criteria->add(ResourceI18nPeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(ResourceI18nPeer::CHAPO)) $criteria->add(ResourceI18nPeer::CHAPO, $this->chapo); - if ($this->isColumnModified(ResourceI18nPeer::POSTSCRIPTUM)) $criteria->add(ResourceI18nPeer::POSTSCRIPTUM, $this->postscriptum); - - 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(ResourceI18nPeer::DATABASE_NAME); - $criteria->add(ResourceI18nPeer::ID, $this->id); - $criteria->add(ResourceI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 ResourceI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - - 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 ResourceI18n 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 ResourceI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new ResourceI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Resource object. - * - * @param Resource $v - * @return ResourceI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setResource(Resource $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aResource = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Resource object, it will not be re-added. - if ($v !== null) { - $v->addResourceI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Resource object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Resource The associated Resource object. - * @throws PropelException - */ - public function getResource(PropelPDO $con = null, $doQuery = true) - { - if ($this->aResource === null && ($this->id !== null) && $doQuery) { - $this->aResource = ResourceQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aResource->addResourceI18ns($this); - */ - } - - return $this->aResource; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aResource instanceof Persistent) { - $this->aResource->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aResource = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(ResourceI18nPeer::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/BaseResourceI18nPeer.php b/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php deleted file mode 100755 index 4baa86d5d..000000000 --- a/core/lib/Thelia/Model/om/BaseResourceI18nPeer.php +++ /dev/null @@ -1,1016 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_COLNAME => array (ResourceI18nPeer::ID, ResourceI18nPeer::LOCALE, ResourceI18nPeer::TITLE, ResourceI18nPeer::DESCRIPTION, ResourceI18nPeer::CHAPO, ResourceI18nPeer::POSTSCRIPTUM, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ResourceI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_COLNAME => array (ResourceI18nPeer::ID => 0, ResourceI18nPeer::LOCALE => 1, ResourceI18nPeer::TITLE => 2, ResourceI18nPeer::DESCRIPTION => 3, ResourceI18nPeer::CHAPO => 4, ResourceI18nPeer::POSTSCRIPTUM => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ResourceI18nPeer::getFieldNames($toType); - $key = isset(ResourceI18nPeer::$fieldKeys[$fromType][$name]) ? ResourceI18nPeer::$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(ResourceI18nPeer::$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, ResourceI18nPeer::$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 ResourceI18nPeer::$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. ResourceI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ResourceI18nPeer::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(ResourceI18nPeer::ID); - $criteria->addSelectColumn(ResourceI18nPeer::LOCALE); - $criteria->addSelectColumn(ResourceI18nPeer::TITLE); - $criteria->addSelectColumn(ResourceI18nPeer::DESCRIPTION); - $criteria->addSelectColumn(ResourceI18nPeer::CHAPO); - $criteria->addSelectColumn(ResourceI18nPeer::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.chapo'); - $criteria->addSelectColumn($alias . '.postscriptum'); - } - } - - /** - * 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(ResourceI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ResourceI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ResourceI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::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 ResourceI18n - * @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 = ResourceI18nPeer::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 ResourceI18nPeer::populateObjects(ResourceI18nPeer::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 directly (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(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ResourceI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ResourceI18nPeer::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 ResourceI18n $obj A ResourceI18n 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->getLocale())); - } // if key === null - ResourceI18nPeer::$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 ResourceI18n 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 ResourceI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 ResourceI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ResourceI18nPeer::$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 ResourceI18n 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(ResourceI18nPeer::$instances[$key])) { - return ResourceI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ResourceI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ResourceI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to resource_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ResourceI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ResourceI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ResourceI18nPeer::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; - ResourceI18nPeer::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 (ResourceI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ResourceI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ResourceI18nPeer::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 + ResourceI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ResourceI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ResourceI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Resource table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinResource(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ResourceI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ResourceI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ResourceI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ResourceI18nPeer::ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of ResourceI18n objects pre-filled with their Resource objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of ResourceI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinResource(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(ResourceI18nPeer::DATABASE_NAME); - } - - ResourceI18nPeer::addSelectColumns($criteria); - $startcol = ResourceI18nPeer::NUM_HYDRATE_COLUMNS; - ResourcePeer::addSelectColumns($criteria); - - $criteria->addJoin(ResourceI18nPeer::ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ResourceI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ResourceI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = ResourceI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ResourceI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ResourcePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ResourcePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ResourcePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (ResourceI18n) to $obj2 (Resource) - $obj2->addResourceI18n($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(ResourceI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ResourceI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(ResourceI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(ResourceI18nPeer::ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of ResourceI18n 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 ResourceI18n 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(ResourceI18nPeer::DATABASE_NAME); - } - - ResourceI18nPeer::addSelectColumns($criteria); - $startcol2 = ResourceI18nPeer::NUM_HYDRATE_COLUMNS; - - ResourcePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ResourcePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(ResourceI18nPeer::ID, ResourcePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = ResourceI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = ResourceI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = ResourceI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - ResourceI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Resource rows - - $key2 = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ResourcePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ResourcePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ResourcePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (ResourceI18n) to the collection in $obj2 (Resource) - $obj2->addResourceI18n($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(ResourceI18nPeer::DATABASE_NAME)->getTable(ResourceI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseResourceI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseResourceI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new ResourceI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ResourceI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a ResourceI18n or Criteria object. - * - * @param mixed $values Criteria or ResourceI18n 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(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from ResourceI18n object - } - - - // Set the correct dbName - $criteria->setDbName(ResourceI18nPeer::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 ResourceI18n or Criteria object. - * - * @param mixed $values Criteria or ResourceI18n 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(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ResourceI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ResourceI18nPeer::ID); - $value = $criteria->remove(ResourceI18nPeer::ID); - if ($value) { - $selectCriteria->add(ResourceI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ResourceI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(ResourceI18nPeer::LOCALE); - $value = $criteria->remove(ResourceI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(ResourceI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ResourceI18nPeer::TABLE_NAME); - } - - } else { // $values is ResourceI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ResourceI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the resource_i18n 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(ResourceI18nPeer::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(ResourceI18nPeer::TABLE_NAME, $con, ResourceI18nPeer::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). - ResourceI18nPeer::clearInstancePool(); - ResourceI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a ResourceI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ResourceI18n 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(ResourceI18nPeer::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. - ResourceI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof ResourceI18n) { // it's a model object - // invalidate the cache for this single object - ResourceI18nPeer::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(ResourceI18nPeer::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(ResourceI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(ResourceI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - ResourceI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(ResourceI18nPeer::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); - ResourceI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given ResourceI18n 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 ResourceI18n $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(ResourceI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ResourceI18nPeer::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(ResourceI18nPeer::DATABASE_NAME, ResourceI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return ResourceI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = ResourceI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ResourceI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(ResourceI18nPeer::DATABASE_NAME); - $criteria->add(ResourceI18nPeer::ID, $id); - $criteria->add(ResourceI18nPeer::LOCALE, $locale); - $v = ResourceI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseResourceI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseResourceI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php b/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php deleted file mode 100755 index e37525132..000000000 --- a/core/lib/Thelia/Model/om/BaseResourceI18nQuery.php +++ /dev/null @@ -1,537 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return ResourceI18n|ResourceI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ResourceI18nPeer::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(ResourceI18nPeer::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 ResourceI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description`, `chapo`, `postscriptum` FROM `resource_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 ResourceI18n(); - $obj->hydrate($row); - ResourceI18nPeer::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 ResourceI18n|ResourceI18n[]|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|ResourceI18n[]|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 ResourceI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(ResourceI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(ResourceI18nPeer::LOCALE, $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 ResourceI18nQuery 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(ResourceI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(ResourceI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByResource() - * - * @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 ResourceI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ResourceI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ResourceI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 ResourceI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourceI18nPeer::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related Resource object - * - * @param Resource|PropelObjectCollection $resource The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByResource($resource, $comparison = null) - { - if ($resource instanceof Resource) { - return $this - ->addUsingAlias(ResourceI18nPeer::ID, $resource->getId(), $comparison); - } elseif ($resource instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(ResourceI18nPeer::ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByResource() only accepts arguments of type Resource or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Resource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function joinResource($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Resource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Resource'); - } - - return $this; - } - - /** - * Use the Resource relation Resource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query - */ - public function useResourceQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery'); - } - - /** - * Exclude object from result - * - * @param ResourceI18n $resourceI18n Object to remove from the list of results - * - * @return ResourceI18nQuery The current query, for fluid interface - */ - public function prune($resourceI18n = null) - { - if ($resourceI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(ResourceI18nPeer::ID), $resourceI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(ResourceI18nPeer::LOCALE), $resourceI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseResourcePeer.php b/core/lib/Thelia/Model/om/BaseResourcePeer.php deleted file mode 100755 index 5e50dc19f..000000000 --- a/core/lib/Thelia/Model/om/BaseResourcePeer.php +++ /dev/null @@ -1,800 +0,0 @@ - array ('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (ResourcePeer::ID, ResourcePeer::CODE, ResourcePeer::CREATED_AT, ResourcePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. ResourcePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (ResourcePeer::ID => 0, ResourcePeer::CODE => 1, ResourcePeer::CREATED_AT => 2, ResourcePeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = ResourcePeer::getFieldNames($toType); - $key = isset(ResourcePeer::$fieldKeys[$fromType][$name]) ? ResourcePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(ResourcePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, ResourcePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return ResourcePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. ResourcePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(ResourcePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(ResourcePeer::ID); - $criteria->addSelectColumn(ResourcePeer::CODE); - $criteria->addSelectColumn(ResourcePeer::CREATED_AT); - $criteria->addSelectColumn(ResourcePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(ResourcePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - ResourcePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(ResourcePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Resource - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = ResourcePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return ResourcePeer::populateObjects(ResourcePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - ResourcePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(ResourcePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Resource $obj A Resource object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - ResourcePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Resource object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Resource) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Resource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(ResourcePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Resource Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(ResourcePeer::$instances[$key])) { - return ResourcePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (ResourcePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - ResourcePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to resource - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in GroupResourcePeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupResourcePeer::clearInstancePool(); - // Invalidate objects in ResourceI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ResourceI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = ResourcePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = ResourcePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = ResourcePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - ResourcePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Resource object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = ResourcePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = ResourcePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + ResourcePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = ResourcePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - ResourcePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(ResourcePeer::DATABASE_NAME)->getTable(ResourcePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseResourcePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseResourcePeer::TABLE_NAME)) { - $dbMap->addTableObject(new ResourceTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return ResourcePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Resource or Criteria object. - * - * @param mixed $values Criteria or Resource object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Resource object - } - - if ($criteria->containsKey(ResourcePeer::ID) && $criteria->keyContainsValue(ResourcePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ResourcePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(ResourcePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Resource or Criteria object. - * - * @param mixed $values Criteria or Resource object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(ResourcePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(ResourcePeer::ID); - $value = $criteria->remove(ResourcePeer::ID); - if ($value) { - $selectCriteria->add(ResourcePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(ResourcePeer::TABLE_NAME); - } - - } else { // $values is Resource object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(ResourcePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the resource table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(ResourcePeer::TABLE_NAME, $con, ResourcePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - ResourcePeer::clearInstancePool(); - ResourcePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Resource or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Resource object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - ResourcePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Resource) { // it's a model object - // invalidate the cache for this single object - ResourcePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - $criteria->add(ResourcePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - ResourcePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(ResourcePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - ResourcePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Resource object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Resource $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(ResourcePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(ResourcePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(ResourcePeer::DATABASE_NAME, ResourcePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Resource - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = ResourcePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - $criteria->add(ResourcePeer::ID, $pk); - - $v = ResourcePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Resource[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(ResourcePeer::DATABASE_NAME); - $criteria->add(ResourcePeer::ID, $pks, Criteria::IN); - $objs = ResourcePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseResourcePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseResourcePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseResourceQuery.php b/core/lib/Thelia/Model/om/BaseResourceQuery.php deleted file mode 100755 index f390091ec..000000000 --- a/core/lib/Thelia/Model/om/BaseResourceQuery.php +++ /dev/null @@ -1,712 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Resource|Resource[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = ResourcePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(ResourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Resource A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Resource A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `created_at`, `updated_at` FROM `resource` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Resource(); - $obj->hydrate($row); - ResourcePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Resource|Resource[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Resource[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(ResourcePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(ResourcePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(ResourcePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(ResourcePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ResourcePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(ResourcePeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ResourcePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(ResourcePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related GroupResource object - * - * @param GroupResource|PropelObjectCollection $groupResource the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByGroupResource($groupResource, $comparison = null) - { - if ($groupResource instanceof GroupResource) { - return $this - ->addUsingAlias(ResourcePeer::ID, $groupResource->getResourceId(), $comparison); - } elseif ($groupResource instanceof PropelObjectCollection) { - return $this - ->useGroupResourceQuery() - ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type GroupResource or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupResource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ResourceQuery The current query, for fluid interface - */ - public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupResource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupResource'); - } - - return $this; - } - - /** - * Use the GroupResource relation GroupResource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query - */ - public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); - } - - /** - * Filter the query by a related ResourceI18n object - * - * @param ResourceI18n|PropelObjectCollection $resourceI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByResourceI18n($resourceI18n, $comparison = null) - { - if ($resourceI18n instanceof ResourceI18n) { - return $this - ->addUsingAlias(ResourcePeer::ID, $resourceI18n->getId(), $comparison); - } elseif ($resourceI18n instanceof PropelObjectCollection) { - return $this - ->useResourceI18nQuery() - ->filterByPrimaryKeys($resourceI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByResourceI18n() only accepts arguments of type ResourceI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the ResourceI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ResourceQuery The current query, for fluid interface - */ - public function joinResourceI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('ResourceI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'ResourceI18n'); - } - - return $this; - } - - /** - * Use the ResourceI18n relation ResourceI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ResourceI18nQuery A secondary query class using the current class as primary query - */ - public function useResourceI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinResourceI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', '\Thelia\Model\ResourceI18nQuery'); - } - - /** - * Filter the query by a related Group object - * using the group_resource table as cross reference - * - * @param Group $group the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ResourceQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = Criteria::EQUAL) - { - return $this - ->useGroupResourceQuery() - ->filterByGroup($group, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param Resource $resource Object to remove from the list of results - * - * @return ResourceQuery The current query, for fluid interface - */ - public function prune($resource = null) - { - if ($resource) { - $this->addUsingAlias(ResourcePeer::ID, $resource->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ResourceQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(ResourcePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ResourceQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(ResourcePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ResourceQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(ResourcePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ResourceQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(ResourcePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return ResourceQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(ResourcePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ResourceQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(ResourcePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ResourceQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; - - return $this - ->joinResourceI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ResourceQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('ResourceI18n'); - $this->with['ResourceI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ResourceI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'ResourceI18n', 'Thelia\Model\ResourceI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseRewriting.php b/core/lib/Thelia/Model/om/BaseRewriting.php deleted file mode 100755 index 4cfcdb7f7..000000000 --- a/core/lib/Thelia/Model/om/BaseRewriting.php +++ /dev/null @@ -1,1615 +0,0 @@ -id; - } - - /** - * Get the [url] column value. - * - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [category_id] column value. - * - * @return int - */ - public function getCategoryId() - { - return $this->category_id; - } - - /** - * Get the [folder_id] column value. - * - * @return int - */ - public function getFolderId() - { - return $this->folder_id; - } - - /** - * Get the [content_id] column value. - * - * @return int - */ - public function getContentId() - { - return $this->content_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = RewritingPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [url] column. - * - * @param string $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setUrl($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->url !== $v) { - $this->url = $v; - $this->modifiedColumns[] = RewritingPeer::URL; - } - - - return $this; - } // setUrl() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = RewritingPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [category_id] column. - * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setCategoryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->category_id !== $v) { - $this->category_id = $v; - $this->modifiedColumns[] = RewritingPeer::CATEGORY_ID; - } - - if ($this->aCategory !== null && $this->aCategory->getId() !== $v) { - $this->aCategory = null; - } - - - return $this; - } // setCategoryId() - - /** - * Set the value of [folder_id] column. - * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setFolderId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->folder_id !== $v) { - $this->folder_id = $v; - $this->modifiedColumns[] = RewritingPeer::FOLDER_ID; - } - - if ($this->aFolder !== null && $this->aFolder->getId() !== $v) { - $this->aFolder = null; - } - - - return $this; - } // setFolderId() - - /** - * Set the value of [content_id] column. - * - * @param int $v new value - * @return Rewriting The current object (for fluent API support) - */ - public function setContentId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->content_id !== $v) { - $this->content_id = $v; - $this->modifiedColumns[] = RewritingPeer::CONTENT_ID; - } - - if ($this->aContent !== null && $this->aContent->getId() !== $v) { - $this->aContent = null; - } - - - return $this; - } // setContentId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Rewriting The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = RewritingPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Rewriting The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = RewritingPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->url = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->category_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->folder_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->content_id = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null; - $this->created_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->updated_at = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 8; // 8 = RewritingPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Rewriting object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - if ($this->aCategory !== null && $this->category_id !== $this->aCategory->getId()) { - $this->aCategory = null; - } - if ($this->aFolder !== null && $this->folder_id !== $this->aFolder->getId()) { - $this->aFolder = null; - } - if ($this->aContent !== null && $this->content_id !== $this->aContent->getId()) { - $this->aContent = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = RewritingPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aProduct = null; - $this->aCategory = null; - $this->aFolder = null; - $this->aContent = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = RewritingQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(RewritingPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(RewritingPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(RewritingPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - RewritingPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->aCategory !== null) { - if ($this->aCategory->isModified() || $this->aCategory->isNew()) { - $affectedRows += $this->aCategory->save($con); - } - $this->setCategory($this->aCategory); - } - - if ($this->aFolder !== null) { - if ($this->aFolder->isModified() || $this->aFolder->isNew()) { - $affectedRows += $this->aFolder->save($con); - } - $this->setFolder($this->aFolder); - } - - if ($this->aContent !== null) { - if ($this->aContent->isModified() || $this->aContent->isNew()) { - $affectedRows += $this->aContent->save($con); - } - $this->setContent($this->aContent); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(RewritingPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(RewritingPeer::URL)) { - $modifiedColumns[':p' . $index++] = '`url`'; - } - if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) { - $modifiedColumns[':p' . $index++] = '`category_id`'; - } - if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) { - $modifiedColumns[':p' . $index++] = '`folder_id`'; - } - if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) { - $modifiedColumns[':p' . $index++] = '`content_id`'; - } - if ($this->isColumnModified(RewritingPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `rewriting` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`url`': - $stmt->bindValue($identifier, $this->url, PDO::PARAM_STR); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`category_id`': - $stmt->bindValue($identifier, $this->category_id, PDO::PARAM_INT); - break; - case '`folder_id`': - $stmt->bindValue($identifier, $this->folder_id, PDO::PARAM_INT); - break; - case '`content_id`': - $stmt->bindValue($identifier, $this->content_id, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - if ($this->aCategory !== null) { - if (!$this->aCategory->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCategory->getValidationFailures()); - } - } - - if ($this->aFolder !== null) { - if (!$this->aFolder->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aFolder->getValidationFailures()); - } - } - - if ($this->aContent !== null) { - if (!$this->aContent->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aContent->getValidationFailures()); - } - } - - - if (($retval = RewritingPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getUrl(); - break; - case 2: - return $this->getProductId(); - break; - case 3: - return $this->getCategoryId(); - break; - case 4: - return $this->getFolderId(); - break; - case 5: - return $this->getContentId(); - break; - case 6: - return $this->getCreatedAt(); - break; - case 7: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Rewriting'][$this->getPrimaryKey()] = true; - $keys = RewritingPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getUrl(), - $keys[2] => $this->getProductId(), - $keys[3] => $this->getCategoryId(), - $keys[4] => $this->getFolderId(), - $keys[5] => $this->getContentId(), - $keys[6] => $this->getCreatedAt(), - $keys[7] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCategory) { - $result['Category'] = $this->aCategory->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aFolder) { - $result['Folder'] = $this->aFolder->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aContent) { - $result['Content'] = $this->aContent->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = RewritingPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setUrl($value); - break; - case 2: - $this->setProductId($value); - break; - case 3: - $this->setCategoryId($value); - break; - case 4: - $this->setFolderId($value); - break; - case 5: - $this->setContentId($value); - break; - case 6: - $this->setCreatedAt($value); - break; - case 7: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = RewritingPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setUrl($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCategoryId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setFolderId($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setContentId($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - - if ($this->isColumnModified(RewritingPeer::ID)) $criteria->add(RewritingPeer::ID, $this->id); - if ($this->isColumnModified(RewritingPeer::URL)) $criteria->add(RewritingPeer::URL, $this->url); - if ($this->isColumnModified(RewritingPeer::PRODUCT_ID)) $criteria->add(RewritingPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(RewritingPeer::CATEGORY_ID)) $criteria->add(RewritingPeer::CATEGORY_ID, $this->category_id); - if ($this->isColumnModified(RewritingPeer::FOLDER_ID)) $criteria->add(RewritingPeer::FOLDER_ID, $this->folder_id); - if ($this->isColumnModified(RewritingPeer::CONTENT_ID)) $criteria->add(RewritingPeer::CONTENT_ID, $this->content_id); - if ($this->isColumnModified(RewritingPeer::CREATED_AT)) $criteria->add(RewritingPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(RewritingPeer::UPDATED_AT)) $criteria->add(RewritingPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - $criteria->add(RewritingPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Rewriting (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setUrl($this->getUrl()); - $copyObj->setProductId($this->getProductId()); - $copyObj->setCategoryId($this->getCategoryId()); - $copyObj->setFolderId($this->getFolderId()); - $copyObj->setContentId($this->getContentId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Rewriting Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return RewritingPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new RewritingPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addRewritings($this); - */ - } - - return $this->aProduct; - } - - /** - * Declares an association between this object and a Category object. - * - * @param Category $v - * @return Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setCategory(Category $v = null) - { - if ($v === null) { - $this->setCategoryId(NULL); - } else { - $this->setCategoryId($v->getId()); - } - - $this->aCategory = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Category object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated Category object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Category The associated Category object. - * @throws PropelException - */ - public function getCategory(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCategory === null && ($this->category_id !== null) && $doQuery) { - $this->aCategory = CategoryQuery::create()->findPk($this->category_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCategory->addRewritings($this); - */ - } - - return $this->aCategory; - } - - /** - * Declares an association between this object and a Folder object. - * - * @param Folder $v - * @return Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setFolder(Folder $v = null) - { - if ($v === null) { - $this->setFolderId(NULL); - } else { - $this->setFolderId($v->getId()); - } - - $this->aFolder = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Folder object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated Folder object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Folder The associated Folder object. - * @throws PropelException - */ - public function getFolder(PropelPDO $con = null, $doQuery = true) - { - if ($this->aFolder === null && ($this->folder_id !== null) && $doQuery) { - $this->aFolder = FolderQuery::create()->findPk($this->folder_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aFolder->addRewritings($this); - */ - } - - return $this->aFolder; - } - - /** - * Declares an association between this object and a Content object. - * - * @param Content $v - * @return Rewriting The current object (for fluent API support) - * @throws PropelException - */ - public function setContent(Content $v = null) - { - if ($v === null) { - $this->setContentId(NULL); - } else { - $this->setContentId($v->getId()); - } - - $this->aContent = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Content object, it will not be re-added. - if ($v !== null) { - $v->addRewriting($this); - } - - - return $this; - } - - - /** - * Get the associated Content object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Content The associated Content object. - * @throws PropelException - */ - public function getContent(PropelPDO $con = null, $doQuery = true) - { - if ($this->aContent === null && ($this->content_id !== null) && $doQuery) { - $this->aContent = ContentQuery::create()->findPk($this->content_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aContent->addRewritings($this); - */ - } - - return $this->aContent; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->url = null; - $this->product_id = null; - $this->category_id = null; - $this->folder_id = null; - $this->content_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - if ($this->aCategory instanceof Persistent) { - $this->aCategory->clearAllReferences($deep); - } - if ($this->aFolder instanceof Persistent) { - $this->aFolder->clearAllReferences($deep); - } - if ($this->aContent instanceof Persistent) { - $this->aContent->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aProduct = null; - $this->aCategory = null; - $this->aFolder = null; - $this->aContent = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(RewritingPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Rewriting The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = RewritingPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseRewritingPeer.php b/core/lib/Thelia/Model/om/BaseRewritingPeer.php deleted file mode 100755 index 1a3558ab0..000000000 --- a/core/lib/Thelia/Model/om/BaseRewritingPeer.php +++ /dev/null @@ -1,2180 +0,0 @@ - array ('Id', 'Url', 'ProductId', 'CategoryId', 'FolderId', 'ContentId', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'url', 'productId', 'categoryId', 'folderId', 'contentId', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (RewritingPeer::ID, RewritingPeer::URL, RewritingPeer::PRODUCT_ID, RewritingPeer::CATEGORY_ID, RewritingPeer::FOLDER_ID, RewritingPeer::CONTENT_ID, RewritingPeer::CREATED_AT, RewritingPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'URL', 'PRODUCT_ID', 'CATEGORY_ID', 'FOLDER_ID', 'CONTENT_ID', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'url', 'product_id', 'category_id', 'folder_id', 'content_id', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. RewritingPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Url' => 1, 'ProductId' => 2, 'CategoryId' => 3, 'FolderId' => 4, 'ContentId' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'url' => 1, 'productId' => 2, 'categoryId' => 3, 'folderId' => 4, 'contentId' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - BasePeer::TYPE_COLNAME => array (RewritingPeer::ID => 0, RewritingPeer::URL => 1, RewritingPeer::PRODUCT_ID => 2, RewritingPeer::CATEGORY_ID => 3, RewritingPeer::FOLDER_ID => 4, RewritingPeer::CONTENT_ID => 5, RewritingPeer::CREATED_AT => 6, RewritingPeer::UPDATED_AT => 7, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'URL' => 1, 'PRODUCT_ID' => 2, 'CATEGORY_ID' => 3, 'FOLDER_ID' => 4, 'CONTENT_ID' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'url' => 1, 'product_id' => 2, 'category_id' => 3, 'folder_id' => 4, 'content_id' => 5, 'created_at' => 6, 'updated_at' => 7, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = RewritingPeer::getFieldNames($toType); - $key = isset(RewritingPeer::$fieldKeys[$fromType][$name]) ? RewritingPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(RewritingPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, RewritingPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return RewritingPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. RewritingPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(RewritingPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(RewritingPeer::ID); - $criteria->addSelectColumn(RewritingPeer::URL); - $criteria->addSelectColumn(RewritingPeer::PRODUCT_ID); - $criteria->addSelectColumn(RewritingPeer::CATEGORY_ID); - $criteria->addSelectColumn(RewritingPeer::FOLDER_ID); - $criteria->addSelectColumn(RewritingPeer::CONTENT_ID); - $criteria->addSelectColumn(RewritingPeer::CREATED_AT); - $criteria->addSelectColumn(RewritingPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.url'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.category_id'); - $criteria->addSelectColumn($alias . '.folder_id'); - $criteria->addSelectColumn($alias . '.content_id'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(RewritingPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Rewriting - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = RewritingPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return RewritingPeer::populateObjects(RewritingPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - RewritingPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Rewriting $obj A Rewriting object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - RewritingPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Rewriting object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Rewriting) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Rewriting object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(RewritingPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Rewriting Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(RewritingPeer::$instances[$key])) { - return RewritingPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (RewritingPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - RewritingPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to rewriting - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = RewritingPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = RewritingPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - RewritingPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Rewriting object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = RewritingPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = RewritingPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + RewritingPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = RewritingPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - RewritingPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Rewriting) to $obj2 (Product) - $obj2->addRewriting($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with their Category objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS; - CategoryPeer::addSelectColumns($criteria); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Rewriting) to $obj2 (Category) - $obj2->addRewriting($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with their Folder objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS; - FolderPeer::addSelectColumns($criteria); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = FolderPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = FolderPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - FolderPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Rewriting) to $obj2 (Folder) - $obj2->addRewriting($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with their Content objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol = RewritingPeer::NUM_HYDRATE_COLUMNS; - ContentPeer::addSelectColumns($criteria); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ContentPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ContentPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ContentPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Rewriting) to $obj2 (Content) - $obj2->addRewriting($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Rewriting objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol6 = $startcol5 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Rewriting) to the collection in $obj2 (Product) - $obj2->addRewriting($obj1); - } // if joined row not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Rewriting) to the collection in $obj3 (Category) - $obj3->addRewriting($obj1); - } // if joined row not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (Rewriting) to the collection in $obj4 (Folder) - $obj4->addRewriting($obj1); - } // if joined row not null - - // Add objects for joined Content rows - - $key5 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol5); - if ($key5 !== null) { - $obj5 = ContentPeer::getInstanceFromPool($key5); - if (!$obj5) { - - $cls = ContentPeer::getOMClass(); - - $obj5 = new $cls(); - $obj5->hydrate($row, $startcol5); - ContentPeer::addInstanceToPool($obj5, $key5); - } // if obj5 loaded - - // Add the $obj1 (Rewriting) to the collection in $obj5 (Content) - $obj5->addRewriting($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Category table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCategory(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Folder table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptFolder(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Content table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptContent(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - RewritingPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Category rows - - $key2 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CategoryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CategoryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CategoryPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj2 (Category) - $obj2->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FolderPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FolderPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FolderPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj3 (Folder) - $obj3->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj4 (Content) - $obj4->addRewriting($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with all related objects except Category. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCategory(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + FolderPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj2 (Product) - $obj2->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key3 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = FolderPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = FolderPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - FolderPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj3 (Folder) - $obj3->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj4 (Content) - $obj4->addRewriting($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with all related objects except Folder. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptFolder(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - ContentPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + ContentPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CONTENT_ID, ContentPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj2 (Product) - $obj2->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj3 (Category) - $obj3->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Content rows - - $key4 = ContentPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = ContentPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = ContentPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - ContentPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj4 (Content) - $obj4->addRewriting($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Rewriting objects pre-filled with all related objects except Content. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Rewriting objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptContent(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - } - - RewritingPeer::addSelectColumns($criteria); - $startcol2 = RewritingPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - CategoryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CategoryPeer::NUM_HYDRATE_COLUMNS; - - FolderPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + FolderPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(RewritingPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::CATEGORY_ID, CategoryPeer::ID, $join_behavior); - - $criteria->addJoin(RewritingPeer::FOLDER_ID, FolderPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = RewritingPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = RewritingPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = RewritingPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - RewritingPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj2 (Product) - $obj2->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Category rows - - $key3 = CategoryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CategoryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CategoryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CategoryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj3 (Category) - $obj3->addRewriting($obj1); - - } // if joined row is not null - - // Add objects for joined Folder rows - - $key4 = FolderPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = FolderPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = FolderPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - FolderPeer::addInstanceToPool($obj4, $key4); - } // if $obj4 already loaded - - // Add the $obj1 (Rewriting) to the collection in $obj4 (Folder) - $obj4->addRewriting($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(RewritingPeer::DATABASE_NAME)->getTable(RewritingPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseRewritingPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseRewritingPeer::TABLE_NAME)) { - $dbMap->addTableObject(new RewritingTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return RewritingPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Rewriting or Criteria object. - * - * @param mixed $values Criteria or Rewriting object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Rewriting object - } - - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Rewriting or Criteria object. - * - * @param mixed $values Criteria or Rewriting object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(RewritingPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(RewritingPeer::ID); - $value = $criteria->remove(RewritingPeer::ID); - if ($value) { - $selectCriteria->add(RewritingPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(RewritingPeer::TABLE_NAME); - } - - } else { // $values is Rewriting object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the rewriting table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(RewritingPeer::TABLE_NAME, $con, RewritingPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - RewritingPeer::clearInstancePool(); - RewritingPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Rewriting or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Rewriting object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - RewritingPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Rewriting) { // it's a model object - // invalidate the cache for this single object - RewritingPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - $criteria->add(RewritingPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - RewritingPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(RewritingPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - RewritingPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Rewriting object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Rewriting $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(RewritingPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(RewritingPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(RewritingPeer::DATABASE_NAME, RewritingPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Rewriting - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = RewritingPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - $criteria->add(RewritingPeer::ID, $pk); - - $v = RewritingPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Rewriting[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(RewritingPeer::DATABASE_NAME); - $criteria->add(RewritingPeer::ID, $pks, Criteria::IN); - $objs = RewritingPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseRewritingPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseRewritingPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseRewritingQuery.php b/core/lib/Thelia/Model/om/BaseRewritingQuery.php deleted file mode 100755 index 2598ce1f4..000000000 --- a/core/lib/Thelia/Model/om/BaseRewritingQuery.php +++ /dev/null @@ -1,995 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = RewritingPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(RewritingPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Rewriting A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Rewriting A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `url`, `product_id`, `category_id`, `folder_id`, `content_id`, `created_at`, `updated_at` FROM `rewriting` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Rewriting(); - $obj->hydrate($row); - RewritingPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Rewriting|Rewriting[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Rewriting[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(RewritingPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(RewritingPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(RewritingPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(RewritingPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the url column - * - * Example usage: - * - * $query->filterByUrl('fooValue'); // WHERE url = 'fooValue' - * $query->filterByUrl('%fooValue%'); // WHERE url LIKE '%fooValue%' - * - * - * @param string $url The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByUrl($url = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($url)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $url)) { - $url = str_replace('*', '%', $url); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(RewritingPeer::URL, $url, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the category_id column - * - * Example usage: - * - * $query->filterByCategoryId(1234); // WHERE category_id = 1234 - * $query->filterByCategoryId(array(12, 34)); // WHERE category_id IN (12, 34) - * $query->filterByCategoryId(array('min' => 12)); // WHERE category_id >= 12 - * $query->filterByCategoryId(array('max' => 12)); // WHERE category_id <= 12 - * - * - * @see filterByCategory() - * - * @param mixed $categoryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByCategoryId($categoryId = null, $comparison = null) - { - if (is_array($categoryId)) { - $useMinMax = false; - if (isset($categoryId['min'])) { - $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($categoryId['max'])) { - $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::CATEGORY_ID, $categoryId, $comparison); - } - - /** - * Filter the query on the folder_id column - * - * Example usage: - * - * $query->filterByFolderId(1234); // WHERE folder_id = 1234 - * $query->filterByFolderId(array(12, 34)); // WHERE folder_id IN (12, 34) - * $query->filterByFolderId(array('min' => 12)); // WHERE folder_id >= 12 - * $query->filterByFolderId(array('max' => 12)); // WHERE folder_id <= 12 - * - * - * @see filterByFolder() - * - * @param mixed $folderId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByFolderId($folderId = null, $comparison = null) - { - if (is_array($folderId)) { - $useMinMax = false; - if (isset($folderId['min'])) { - $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($folderId['max'])) { - $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::FOLDER_ID, $folderId, $comparison); - } - - /** - * Filter the query on the content_id column - * - * Example usage: - * - * $query->filterByContentId(1234); // WHERE content_id = 1234 - * $query->filterByContentId(array(12, 34)); // WHERE content_id IN (12, 34) - * $query->filterByContentId(array('min' => 12)); // WHERE content_id >= 12 - * $query->filterByContentId(array('max' => 12)); // WHERE content_id <= 12 - * - * - * @see filterByContent() - * - * @param mixed $contentId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByContentId($contentId = null, $comparison = null) - { - if (is_array($contentId)) { - $useMinMax = false; - if (isset($contentId['min'])) { - $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($contentId['max'])) { - $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::CONTENT_ID, $contentId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(RewritingPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return RewritingQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related Category object - * - * @param Category|PropelObjectCollection $category The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCategory($category, $comparison = null) - { - if ($category instanceof Category) { - return $this - ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->getId(), $comparison); - } elseif ($category instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingPeer::CATEGORY_ID, $category->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCategory() only accepts arguments of type Category or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Category relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return RewritingQuery The current query, for fluid interface - */ - public function joinCategory($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Category'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Category'); - } - - return $this; - } - - /** - * Use the Category relation Category object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CategoryQuery A secondary query class using the current class as primary query - */ - public function useCategoryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCategory($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Category', '\Thelia\Model\CategoryQuery'); - } - - /** - * Filter the query by a related Folder object - * - * @param Folder|PropelObjectCollection $folder The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByFolder($folder, $comparison = null) - { - if ($folder instanceof Folder) { - return $this - ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->getId(), $comparison); - } elseif ($folder instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingPeer::FOLDER_ID, $folder->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByFolder() only accepts arguments of type Folder or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Folder relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return RewritingQuery The current query, for fluid interface - */ - public function joinFolder($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Folder'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Folder'); - } - - return $this; - } - - /** - * Use the Folder relation Folder object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\FolderQuery A secondary query class using the current class as primary query - */ - public function useFolderQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinFolder($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Folder', '\Thelia\Model\FolderQuery'); - } - - /** - * Filter the query by a related Content object - * - * @param Content|PropelObjectCollection $content The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return RewritingQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByContent($content, $comparison = null) - { - if ($content instanceof Content) { - return $this - ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->getId(), $comparison); - } elseif ($content instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(RewritingPeer::CONTENT_ID, $content->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByContent() only accepts arguments of type Content or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Content relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return RewritingQuery The current query, for fluid interface - */ - public function joinContent($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Content'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Content'); - } - - return $this; - } - - /** - * Use the Content relation Content object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ContentQuery A secondary query class using the current class as primary query - */ - public function useContentQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinContent($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Content', '\Thelia\Model\ContentQuery'); - } - - /** - * Exclude object from result - * - * @param Rewriting $rewriting Object to remove from the list of results - * - * @return RewritingQuery The current query, for fluid interface - */ - public function prune($rewriting = null) - { - if ($rewriting) { - $this->addUsingAlias(RewritingPeer::ID, $rewriting->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return RewritingQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(RewritingPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return RewritingQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(RewritingPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return RewritingQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(RewritingPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return RewritingQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(RewritingPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return RewritingQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(RewritingPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return RewritingQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(RewritingPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseStock.php b/core/lib/Thelia/Model/om/BaseStock.php deleted file mode 100755 index f6f4458c9..000000000 --- a/core/lib/Thelia/Model/om/BaseStock.php +++ /dev/null @@ -1,1397 +0,0 @@ -id; - } - - /** - * Get the [combination_id] column value. - * - * @return int - */ - public function getCombinationId() - { - return $this->combination_id; - } - - /** - * Get the [product_id] column value. - * - * @return int - */ - public function getProductId() - { - return $this->product_id; - } - - /** - * Get the [increase] column value. - * - * @return double - */ - public function getIncrease() - { - return $this->increase; - } - - /** - * Get the [value] column value. - * - * @return double - */ - public function getValue() - { - return $this->value; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Stock The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = StockPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [combination_id] column. - * - * @param int $v new value - * @return Stock The current object (for fluent API support) - */ - public function setCombinationId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->combination_id !== $v) { - $this->combination_id = $v; - $this->modifiedColumns[] = StockPeer::COMBINATION_ID; - } - - if ($this->aCombination !== null && $this->aCombination->getId() !== $v) { - $this->aCombination = null; - } - - - return $this; - } // setCombinationId() - - /** - * Set the value of [product_id] column. - * - * @param int $v new value - * @return Stock The current object (for fluent API support) - */ - public function setProductId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->product_id !== $v) { - $this->product_id = $v; - $this->modifiedColumns[] = StockPeer::PRODUCT_ID; - } - - if ($this->aProduct !== null && $this->aProduct->getId() !== $v) { - $this->aProduct = null; - } - - - return $this; - } // setProductId() - - /** - * Set the value of [increase] column. - * - * @param double $v new value - * @return Stock The current object (for fluent API support) - */ - public function setIncrease($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->increase !== $v) { - $this->increase = $v; - $this->modifiedColumns[] = StockPeer::INCREASE; - } - - - return $this; - } // setIncrease() - - /** - * Set the value of [value] column. - * - * @param double $v new value - * @return Stock The current object (for fluent API support) - */ - public function setValue($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->value !== $v) { - $this->value = $v; - $this->modifiedColumns[] = StockPeer::VALUE; - } - - - return $this; - } // setValue() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Stock The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = StockPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Stock The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = StockPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->combination_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->product_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->increase = ($row[$startcol + 3] !== null) ? (double) $row[$startcol + 3] : null; - $this->value = ($row[$startcol + 4] !== null) ? (double) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = StockPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Stock object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aCombination !== null && $this->combination_id !== $this->aCombination->getId()) { - $this->aCombination = null; - } - if ($this->aProduct !== null && $this->product_id !== $this->aProduct->getId()) { - $this->aProduct = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = StockPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aCombination = null; - $this->aProduct = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = StockQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(StockPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(StockPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(StockPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - StockPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCombination !== null) { - if ($this->aCombination->isModified() || $this->aCombination->isNew()) { - $affectedRows += $this->aCombination->save($con); - } - $this->setCombination($this->aCombination); - } - - if ($this->aProduct !== null) { - if ($this->aProduct->isModified() || $this->aProduct->isNew()) { - $affectedRows += $this->aProduct->save($con); - } - $this->setProduct($this->aProduct); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = StockPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . StockPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(StockPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(StockPeer::COMBINATION_ID)) { - $modifiedColumns[':p' . $index++] = '`combination_id`'; - } - if ($this->isColumnModified(StockPeer::PRODUCT_ID)) { - $modifiedColumns[':p' . $index++] = '`product_id`'; - } - if ($this->isColumnModified(StockPeer::INCREASE)) { - $modifiedColumns[':p' . $index++] = '`increase`'; - } - if ($this->isColumnModified(StockPeer::VALUE)) { - $modifiedColumns[':p' . $index++] = '`value`'; - } - if ($this->isColumnModified(StockPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(StockPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `stock` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`combination_id`': - $stmt->bindValue($identifier, $this->combination_id, PDO::PARAM_INT); - break; - case '`product_id`': - $stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); - break; - case '`increase`': - $stmt->bindValue($identifier, $this->increase, PDO::PARAM_STR); - break; - case '`value`': - $stmt->bindValue($identifier, $this->value, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aCombination !== null) { - if (!$this->aCombination->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCombination->getValidationFailures()); - } - } - - if ($this->aProduct !== null) { - if (!$this->aProduct->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aProduct->getValidationFailures()); - } - } - - - if (($retval = StockPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = StockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCombinationId(); - break; - case 2: - return $this->getProductId(); - break; - case 3: - return $this->getIncrease(); - break; - case 4: - return $this->getValue(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Stock'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Stock'][$this->getPrimaryKey()] = true; - $keys = StockPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCombinationId(), - $keys[2] => $this->getProductId(), - $keys[3] => $this->getIncrease(), - $keys[4] => $this->getValue(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aCombination) { - $result['Combination'] = $this->aCombination->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aProduct) { - $result['Product'] = $this->aProduct->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = StockPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCombinationId($value); - break; - case 2: - $this->setProductId($value); - break; - case 3: - $this->setIncrease($value); - break; - case 4: - $this->setValue($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = StockPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCombinationId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setProductId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setIncrease($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setValue($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(StockPeer::DATABASE_NAME); - - if ($this->isColumnModified(StockPeer::ID)) $criteria->add(StockPeer::ID, $this->id); - if ($this->isColumnModified(StockPeer::COMBINATION_ID)) $criteria->add(StockPeer::COMBINATION_ID, $this->combination_id); - if ($this->isColumnModified(StockPeer::PRODUCT_ID)) $criteria->add(StockPeer::PRODUCT_ID, $this->product_id); - if ($this->isColumnModified(StockPeer::INCREASE)) $criteria->add(StockPeer::INCREASE, $this->increase); - if ($this->isColumnModified(StockPeer::VALUE)) $criteria->add(StockPeer::VALUE, $this->value); - if ($this->isColumnModified(StockPeer::CREATED_AT)) $criteria->add(StockPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(StockPeer::UPDATED_AT)) $criteria->add(StockPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(StockPeer::DATABASE_NAME); - $criteria->add(StockPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Stock (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCombinationId($this->getCombinationId()); - $copyObj->setProductId($this->getProductId()); - $copyObj->setIncrease($this->getIncrease()); - $copyObj->setValue($this->getValue()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Stock Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return StockPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new StockPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Combination object. - * - * @param Combination $v - * @return Stock The current object (for fluent API support) - * @throws PropelException - */ - public function setCombination(Combination $v = null) - { - if ($v === null) { - $this->setCombinationId(NULL); - } else { - $this->setCombinationId($v->getId()); - } - - $this->aCombination = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Combination object, it will not be re-added. - if ($v !== null) { - $v->addStock($this); - } - - - return $this; - } - - - /** - * Get the associated Combination object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Combination The associated Combination object. - * @throws PropelException - */ - public function getCombination(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCombination === null && ($this->combination_id !== null) && $doQuery) { - $this->aCombination = CombinationQuery::create()->findPk($this->combination_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCombination->addStocks($this); - */ - } - - return $this->aCombination; - } - - /** - * Declares an association between this object and a Product object. - * - * @param Product $v - * @return Stock The current object (for fluent API support) - * @throws PropelException - */ - public function setProduct(Product $v = null) - { - if ($v === null) { - $this->setProductId(NULL); - } else { - $this->setProductId($v->getId()); - } - - $this->aProduct = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Product object, it will not be re-added. - if ($v !== null) { - $v->addStock($this); - } - - - return $this; - } - - - /** - * Get the associated Product object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Product The associated Product object. - * @throws PropelException - */ - public function getProduct(PropelPDO $con = null, $doQuery = true) - { - if ($this->aProduct === null && ($this->product_id !== null) && $doQuery) { - $this->aProduct = ProductQuery::create()->findPk($this->product_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aProduct->addStocks($this); - */ - } - - return $this->aProduct; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->combination_id = null; - $this->product_id = null; - $this->increase = null; - $this->value = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aCombination instanceof Persistent) { - $this->aCombination->clearAllReferences($deep); - } - if ($this->aProduct instanceof Persistent) { - $this->aProduct->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aCombination = null; - $this->aProduct = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(StockPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Stock The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = StockPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseStockPeer.php b/core/lib/Thelia/Model/om/BaseStockPeer.php deleted file mode 100755 index 8a97eeab6..000000000 --- a/core/lib/Thelia/Model/om/BaseStockPeer.php +++ /dev/null @@ -1,1433 +0,0 @@ - array ('Id', 'CombinationId', 'ProductId', 'Increase', 'Value', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'combinationId', 'productId', 'increase', 'value', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (StockPeer::ID, StockPeer::COMBINATION_ID, StockPeer::PRODUCT_ID, StockPeer::INCREASE, StockPeer::VALUE, StockPeer::CREATED_AT, StockPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'COMBINATION_ID', 'PRODUCT_ID', 'INCREASE', 'VALUE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'combination_id', 'product_id', 'increase', 'value', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. StockPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'CombinationId' => 1, 'ProductId' => 2, 'Increase' => 3, 'Value' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'combinationId' => 1, 'productId' => 2, 'increase' => 3, 'value' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (StockPeer::ID => 0, StockPeer::COMBINATION_ID => 1, StockPeer::PRODUCT_ID => 2, StockPeer::INCREASE => 3, StockPeer::VALUE => 4, StockPeer::CREATED_AT => 5, StockPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'COMBINATION_ID' => 1, 'PRODUCT_ID' => 2, 'INCREASE' => 3, 'VALUE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'combination_id' => 1, 'product_id' => 2, 'increase' => 3, 'value' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = StockPeer::getFieldNames($toType); - $key = isset(StockPeer::$fieldKeys[$fromType][$name]) ? StockPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(StockPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, StockPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return StockPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. StockPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(StockPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(StockPeer::ID); - $criteria->addSelectColumn(StockPeer::COMBINATION_ID); - $criteria->addSelectColumn(StockPeer::PRODUCT_ID); - $criteria->addSelectColumn(StockPeer::INCREASE); - $criteria->addSelectColumn(StockPeer::VALUE); - $criteria->addSelectColumn(StockPeer::CREATED_AT); - $criteria->addSelectColumn(StockPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.combination_id'); - $criteria->addSelectColumn($alias . '.product_id'); - $criteria->addSelectColumn($alias . '.increase'); - $criteria->addSelectColumn($alias . '.value'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(StockPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Stock - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = StockPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return StockPeer::populateObjects(StockPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - StockPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Stock $obj A Stock object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - StockPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Stock object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Stock) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Stock object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(StockPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Stock Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(StockPeer::$instances[$key])) { - return StockPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (StockPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - StockPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to stock - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = StockPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = StockPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - StockPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Stock object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = StockPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = StockPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + StockPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = StockPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - StockPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Combination table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCombination(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Stock objects pre-filled with their Combination objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Stock objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(StockPeer::DATABASE_NAME); - } - - StockPeer::addSelectColumns($criteria); - $startcol = StockPeer::NUM_HYDRATE_COLUMNS; - CombinationPeer::addSelectColumns($criteria); - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = StockPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - StockPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CombinationPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CombinationPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CombinationPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Stock) to $obj2 (Combination) - $obj2->addStock($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Stock objects pre-filled with their Product objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Stock objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(StockPeer::DATABASE_NAME); - } - - StockPeer::addSelectColumns($criteria); - $startcol = StockPeer::NUM_HYDRATE_COLUMNS; - ProductPeer::addSelectColumns($criteria); - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = StockPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - StockPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (Stock) to $obj2 (Product) - $obj2->addStock($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of Stock objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Stock objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(StockPeer::DATABASE_NAME); - } - - StockPeer::addSelectColumns($criteria); - $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS; - - CombinationPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CombinationPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = StockPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - StockPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Combination rows - - $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CombinationPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CombinationPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CombinationPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (Stock) to the collection in $obj2 (Combination) - $obj2->addStock($obj1); - } // if joined row not null - - // Add objects for joined Product rows - - $key3 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = ProductPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = ProductPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - ProductPeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (Stock) to the collection in $obj3 (Product) - $obj3->addStock($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Combination table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCombination(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Product table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptProduct(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(StockPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - StockPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of Stock objects pre-filled with all related objects except Combination. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Stock objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCombination(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(StockPeer::DATABASE_NAME); - } - - StockPeer::addSelectColumns($criteria); - $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS; - - ProductPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + ProductPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(StockPeer::PRODUCT_ID, ProductPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = StockPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - StockPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Product rows - - $key2 = ProductPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = ProductPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = ProductPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - ProductPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Stock) to the collection in $obj2 (Product) - $obj2->addStock($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of Stock objects pre-filled with all related objects except Product. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of Stock objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptProduct(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(StockPeer::DATABASE_NAME); - } - - StockPeer::addSelectColumns($criteria); - $startcol2 = StockPeer::NUM_HYDRATE_COLUMNS; - - CombinationPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + CombinationPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(StockPeer::COMBINATION_ID, CombinationPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = StockPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = StockPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = StockPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - StockPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Combination rows - - $key2 = CombinationPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = CombinationPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CombinationPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - CombinationPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (Stock) to the collection in $obj2 (Combination) - $obj2->addStock($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(StockPeer::DATABASE_NAME)->getTable(StockPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseStockPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseStockPeer::TABLE_NAME)) { - $dbMap->addTableObject(new StockTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return StockPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Stock or Criteria object. - * - * @param mixed $values Criteria or Stock object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Stock object - } - - if ($criteria->containsKey(StockPeer::ID) && $criteria->keyContainsValue(StockPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.StockPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Stock or Criteria object. - * - * @param mixed $values Criteria or Stock object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(StockPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(StockPeer::ID); - $value = $criteria->remove(StockPeer::ID); - if ($value) { - $selectCriteria->add(StockPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(StockPeer::TABLE_NAME); - } - - } else { // $values is Stock object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the stock table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(StockPeer::TABLE_NAME, $con, StockPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - StockPeer::clearInstancePool(); - StockPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Stock or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Stock object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - StockPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Stock) { // it's a model object - // invalidate the cache for this single object - StockPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(StockPeer::DATABASE_NAME); - $criteria->add(StockPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - StockPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(StockPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - StockPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Stock object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Stock $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(StockPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(StockPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(StockPeer::DATABASE_NAME, StockPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Stock - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = StockPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(StockPeer::DATABASE_NAME); - $criteria->add(StockPeer::ID, $pk); - - $v = StockPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Stock[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(StockPeer::DATABASE_NAME); - $criteria->add(StockPeer::ID, $pks, Criteria::IN); - $objs = StockPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseStockPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseStockPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseStockQuery.php b/core/lib/Thelia/Model/om/BaseStockQuery.php deleted file mode 100755 index 792084e78..000000000 --- a/core/lib/Thelia/Model/om/BaseStockQuery.php +++ /dev/null @@ -1,796 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Stock|Stock[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = StockPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(StockPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Stock A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Stock A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `combination_id`, `product_id`, `increase`, `value`, `created_at`, `updated_at` FROM `stock` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Stock(); - $obj->hydrate($row); - StockPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Stock|Stock[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Stock[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(StockPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(StockPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(StockPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(StockPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the combination_id column - * - * Example usage: - * - * $query->filterByCombinationId(1234); // WHERE combination_id = 1234 - * $query->filterByCombinationId(array(12, 34)); // WHERE combination_id IN (12, 34) - * $query->filterByCombinationId(array('min' => 12)); // WHERE combination_id >= 12 - * $query->filterByCombinationId(array('max' => 12)); // WHERE combination_id <= 12 - * - * - * @see filterByCombination() - * - * @param mixed $combinationId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByCombinationId($combinationId = null, $comparison = null) - { - if (is_array($combinationId)) { - $useMinMax = false; - if (isset($combinationId['min'])) { - $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($combinationId['max'])) { - $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::COMBINATION_ID, $combinationId, $comparison); - } - - /** - * Filter the query on the product_id column - * - * Example usage: - * - * $query->filterByProductId(1234); // WHERE product_id = 1234 - * $query->filterByProductId(array(12, 34)); // WHERE product_id IN (12, 34) - * $query->filterByProductId(array('min' => 12)); // WHERE product_id >= 12 - * $query->filterByProductId(array('max' => 12)); // WHERE product_id <= 12 - * - * - * @see filterByProduct() - * - * @param mixed $productId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByProductId($productId = null, $comparison = null) - { - if (is_array($productId)) { - $useMinMax = false; - if (isset($productId['min'])) { - $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($productId['max'])) { - $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::PRODUCT_ID, $productId, $comparison); - } - - /** - * Filter the query on the increase column - * - * Example usage: - * - * $query->filterByIncrease(1234); // WHERE increase = 1234 - * $query->filterByIncrease(array(12, 34)); // WHERE increase IN (12, 34) - * $query->filterByIncrease(array('min' => 12)); // WHERE increase >= 12 - * $query->filterByIncrease(array('max' => 12)); // WHERE increase <= 12 - * - * - * @param mixed $increase The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByIncrease($increase = null, $comparison = null) - { - if (is_array($increase)) { - $useMinMax = false; - if (isset($increase['min'])) { - $this->addUsingAlias(StockPeer::INCREASE, $increase['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($increase['max'])) { - $this->addUsingAlias(StockPeer::INCREASE, $increase['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::INCREASE, $increase, $comparison); - } - - /** - * Filter the query on the value column - * - * Example usage: - * - * $query->filterByValue(1234); // WHERE value = 1234 - * $query->filterByValue(array(12, 34)); // WHERE value IN (12, 34) - * $query->filterByValue(array('min' => 12)); // WHERE value >= 12 - * $query->filterByValue(array('max' => 12)); // WHERE value <= 12 - * - * - * @param mixed $value The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByValue($value = null, $comparison = null) - { - if (is_array($value)) { - $useMinMax = false; - if (isset($value['min'])) { - $this->addUsingAlias(StockPeer::VALUE, $value['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($value['max'])) { - $this->addUsingAlias(StockPeer::VALUE, $value['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::VALUE, $value, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(StockPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Combination object - * - * @param Combination|PropelObjectCollection $combination The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCombination($combination, $comparison = null) - { - if ($combination instanceof Combination) { - return $this - ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->getId(), $comparison); - } elseif ($combination instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(StockPeer::COMBINATION_ID, $combination->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCombination() only accepts arguments of type Combination or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Combination relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return StockQuery The current query, for fluid interface - */ - public function joinCombination($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Combination'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Combination'); - } - - return $this; - } - - /** - * Use the Combination relation Combination object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CombinationQuery A secondary query class using the current class as primary query - */ - public function useCombinationQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCombination($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Combination', '\Thelia\Model\CombinationQuery'); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return StockQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(StockPeer::PRODUCT_ID, $product->getId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(StockPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return StockQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Exclude object from result - * - * @param Stock $stock Object to remove from the list of results - * - * @return StockQuery The current query, for fluid interface - */ - public function prune($stock = null) - { - if ($stock) { - $this->addUsingAlias(StockPeer::ID, $stock->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return StockQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(StockPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return StockQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(StockPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return StockQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(StockPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return StockQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(StockPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return StockQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(StockPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return StockQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(StockPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseTax.php b/core/lib/Thelia/Model/om/BaseTax.php deleted file mode 100755 index 9d7ad3c80..000000000 --- a/core/lib/Thelia/Model/om/BaseTax.php +++ /dev/null @@ -1,1842 +0,0 @@ -id; - } - - /** - * Get the [rate] column value. - * - * @return double - */ - public function getRate() - { - return $this->rate; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return Tax The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = TaxPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [rate] column. - * - * @param double $v new value - * @return Tax The current object (for fluent API support) - */ - public function setRate($v) - { - if ($v !== null && is_numeric($v)) { - $v = (double) $v; - } - - if ($this->rate !== $v) { - $this->rate = $v; - $this->modifiedColumns[] = TaxPeer::RATE; - } - - - return $this; - } // setRate() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Tax The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = TaxPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return Tax The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = TaxPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->rate = ($row[$startcol + 1] !== null) ? (double) $row[$startcol + 1] : null; - $this->created_at = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->updated_at = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = TaxPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating Tax object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = TaxPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collTaxRuleCountrys = null; - - $this->collTaxI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = TaxQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(TaxPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(TaxPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(TaxPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - TaxPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->taxRuleCountrysScheduledForDeletion !== null) { - if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) { - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) { - // need to save related object because we set the relation to null - $taxRuleCountry->save($con); - } - $this->taxRuleCountrysScheduledForDeletion = null; - } - } - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->taxI18nsScheduledForDeletion !== null) { - if (!$this->taxI18nsScheduledForDeletion->isEmpty()) { - TaxI18nQuery::create() - ->filterByPrimaryKeys($this->taxI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->taxI18nsScheduledForDeletion = null; - } - } - - if ($this->collTaxI18ns !== null) { - foreach ($this->collTaxI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = TaxPeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxPeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(TaxPeer::RATE)) { - $modifiedColumns[':p' . $index++] = '`rate`'; - } - if ($this->isColumnModified(TaxPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(TaxPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `tax` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`rate`': - $stmt->bindValue($identifier, $this->rate, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = TaxPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collTaxI18ns !== null) { - foreach ($this->collTaxI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getRate(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Tax'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Tax'][$this->getPrimaryKey()] = true; - $keys = TaxPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getRate(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collTaxRuleCountrys) { - $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collTaxI18ns) { - $result['TaxI18ns'] = $this->collTaxI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setRate($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = TaxPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setRate($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(TaxPeer::DATABASE_NAME); - - if ($this->isColumnModified(TaxPeer::ID)) $criteria->add(TaxPeer::ID, $this->id); - if ($this->isColumnModified(TaxPeer::RATE)) $criteria->add(TaxPeer::RATE, $this->rate); - if ($this->isColumnModified(TaxPeer::CREATED_AT)) $criteria->add(TaxPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(TaxPeer::UPDATED_AT)) $criteria->add(TaxPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(TaxPeer::DATABASE_NAME); - $criteria->add(TaxPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of Tax (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setRate($this->getRate()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getTaxRuleCountrys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); - } - } - - foreach ($this->getTaxI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return Tax Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return TaxPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new TaxPeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); - } - if ('TaxI18n' == $relationName) { - $this->initTaxI18ns(); - } - } - - /** - * Clears out the collTaxRuleCountrys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return Tax The current object (for fluent API support) - * @see addTaxRuleCountrys() - */ - public function clearTaxRuleCountrys() - { - $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized - $this->collTaxRuleCountrysPartial = null; - - return $this; - } - - /** - * reset is the collTaxRuleCountrys collection loaded partially - * - * @return void - */ - public function resetPartialTaxRuleCountrys($v = true) - { - $this->collTaxRuleCountrysPartial = $v; - } - - /** - * Initializes the collTaxRuleCountrys collection. - * - * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initTaxRuleCountrys($overrideExisting = true) - { - if (null !== $this->collTaxRuleCountrys && !$overrideExisting) { - return; - } - $this->collTaxRuleCountrys = new PropelObjectCollection(); - $this->collTaxRuleCountrys->setModel('TaxRuleCountry'); - } - - /** - * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Tax is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - * @throws PropelException - */ - public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - // return empty collection - $this->initTaxRuleCountrys(); - } else { - $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria) - ->filterByTax($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) { - $this->initTaxRuleCountrys(false); - - foreach($collTaxRuleCountrys as $obj) { - if (false == $this->collTaxRuleCountrys->contains($obj)) { - $this->collTaxRuleCountrys->append($obj); - } - } - - $this->collTaxRuleCountrysPartial = true; - } - - $collTaxRuleCountrys->getInternalIterator()->rewind(); - return $collTaxRuleCountrys; - } - - if($partial && $this->collTaxRuleCountrys) { - foreach($this->collTaxRuleCountrys as $obj) { - if($obj->isNew()) { - $collTaxRuleCountrys[] = $obj; - } - } - } - - $this->collTaxRuleCountrys = $collTaxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - } - } - - return $this->collTaxRuleCountrys; - } - - /** - * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $taxRuleCountrys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Tax The current object (for fluent API support) - */ - public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) - { - $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - - $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); - - foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { - $taxRuleCountryRemoved->setTax(null); - } - - $this->collTaxRuleCountrys = null; - foreach ($taxRuleCountrys as $taxRuleCountry) { - $this->addTaxRuleCountry($taxRuleCountry); - } - - $this->collTaxRuleCountrys = $taxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - - return $this; - } - - /** - * Returns the number of related TaxRuleCountry objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxRuleCountry objects. - * @throws PropelException - */ - public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTax($this) - ->count($con); - } - - return count($this->collTaxRuleCountrys); - } - - /** - * Method called to associate a TaxRuleCountry object to this object - * through the TaxRuleCountry foreign key attribute. - * - * @param TaxRuleCountry $l TaxRuleCountry - * @return Tax The current object (for fluent API support) - */ - public function addTaxRuleCountry(TaxRuleCountry $l) - { - if ($this->collTaxRuleCountrys === null) { - $this->initTaxRuleCountrys(); - $this->collTaxRuleCountrysPartial = true; - } - if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddTaxRuleCountry($l); - } - - return $this; - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. - */ - protected function doAddTaxRuleCountry($taxRuleCountry) - { - $this->collTaxRuleCountrys[]= $taxRuleCountry; - $taxRuleCountry->setTax($this); - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. - * @return Tax The current object (for fluent API support) - */ - public function removeTaxRuleCountry($taxRuleCountry) - { - if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) { - $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry)); - if (null === $this->taxRuleCountrysScheduledForDeletion) { - $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys; - $this->taxRuleCountrysScheduledForDeletion->clear(); - } - $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; - $taxRuleCountry->setTax(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Tax is new, it will return - * an empty collection; or if this Tax has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Tax. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinTaxRule($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('TaxRule', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Tax is new, it will return - * an empty collection; or if this Tax has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Tax. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Country', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - /** - * Clears out the collTaxI18ns 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 Tax The current object (for fluent API support) - * @see addTaxI18ns() - */ - public function clearTaxI18ns() - { - $this->collTaxI18ns = null; // important to set this to null since that means it is uninitialized - $this->collTaxI18nsPartial = null; - - return $this; - } - - /** - * reset is the collTaxI18ns collection loaded partially - * - * @return void - */ - public function resetPartialTaxI18ns($v = true) - { - $this->collTaxI18nsPartial = $v; - } - - /** - * Initializes the collTaxI18ns collection. - * - * By default this just sets the collTaxI18ns collection to an empty array (like clearcollTaxI18ns()); - * 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 initTaxI18ns($overrideExisting = true) - { - if (null !== $this->collTaxI18ns && !$overrideExisting) { - return; - } - $this->collTaxI18ns = new PropelObjectCollection(); - $this->collTaxI18ns->setModel('TaxI18n'); - } - - /** - * Gets an array of TaxI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this Tax is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxI18n[] List of TaxI18n objects - * @throws PropelException - */ - public function getTaxI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxI18nsPartial && !$this->isNew(); - if (null === $this->collTaxI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxI18ns) { - // return empty collection - $this->initTaxI18ns(); - } else { - $collTaxI18ns = TaxI18nQuery::create(null, $criteria) - ->filterByTax($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxI18nsPartial && count($collTaxI18ns)) { - $this->initTaxI18ns(false); - - foreach($collTaxI18ns as $obj) { - if (false == $this->collTaxI18ns->contains($obj)) { - $this->collTaxI18ns->append($obj); - } - } - - $this->collTaxI18nsPartial = true; - } - - $collTaxI18ns->getInternalIterator()->rewind(); - return $collTaxI18ns; - } - - if($partial && $this->collTaxI18ns) { - foreach($this->collTaxI18ns as $obj) { - if($obj->isNew()) { - $collTaxI18ns[] = $obj; - } - } - } - - $this->collTaxI18ns = $collTaxI18ns; - $this->collTaxI18nsPartial = false; - } - } - - return $this->collTaxI18ns; - } - - /** - * Sets a collection of TaxI18n 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 $taxI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return Tax The current object (for fluent API support) - */ - public function setTaxI18ns(PropelCollection $taxI18ns, PropelPDO $con = null) - { - $taxI18nsToDelete = $this->getTaxI18ns(new Criteria(), $con)->diff($taxI18ns); - - $this->taxI18nsScheduledForDeletion = unserialize(serialize($taxI18nsToDelete)); - - foreach ($taxI18nsToDelete as $taxI18nRemoved) { - $taxI18nRemoved->setTax(null); - } - - $this->collTaxI18ns = null; - foreach ($taxI18ns as $taxI18n) { - $this->addTaxI18n($taxI18n); - } - - $this->collTaxI18ns = $taxI18ns; - $this->collTaxI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related TaxI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxI18n objects. - * @throws PropelException - */ - public function countTaxI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxI18nsPartial && !$this->isNew(); - if (null === $this->collTaxI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getTaxI18ns()); - } - $query = TaxI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTax($this) - ->count($con); - } - - return count($this->collTaxI18ns); - } - - /** - * Method called to associate a TaxI18n object to this object - * through the TaxI18n foreign key attribute. - * - * @param TaxI18n $l TaxI18n - * @return Tax The current object (for fluent API support) - */ - public function addTaxI18n(TaxI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collTaxI18ns === null) { - $this->initTaxI18ns(); - $this->collTaxI18nsPartial = true; - } - if (!in_array($l, $this->collTaxI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddTaxI18n($l); - } - - return $this; - } - - /** - * @param TaxI18n $taxI18n The taxI18n object to add. - */ - protected function doAddTaxI18n($taxI18n) - { - $this->collTaxI18ns[]= $taxI18n; - $taxI18n->setTax($this); - } - - /** - * @param TaxI18n $taxI18n The taxI18n object to remove. - * @return Tax The current object (for fluent API support) - */ - public function removeTaxI18n($taxI18n) - { - if ($this->getTaxI18ns()->contains($taxI18n)) { - $this->collTaxI18ns->remove($this->collTaxI18ns->search($taxI18n)); - if (null === $this->taxI18nsScheduledForDeletion) { - $this->taxI18nsScheduledForDeletion = clone $this->collTaxI18ns; - $this->taxI18nsScheduledForDeletion->clear(); - } - $this->taxI18nsScheduledForDeletion[]= clone $taxI18n; - $taxI18n->setTax(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->rate = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collTaxRuleCountrys) { - foreach ($this->collTaxRuleCountrys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collTaxI18ns) { - foreach ($this->collTaxI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); - } - $this->collTaxRuleCountrys = null; - if ($this->collTaxI18ns instanceof PropelCollection) { - $this->collTaxI18ns->clearIterator(); - } - $this->collTaxI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(TaxPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return Tax The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = TaxPeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return Tax The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return TaxI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collTaxI18ns) { - foreach ($this->collTaxI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new TaxI18n(); - $translation->setLocale($locale); - } else { - $translation = TaxI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addTaxI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return Tax The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - TaxI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collTaxI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collTaxI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return TaxI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxI18n.php b/core/lib/Thelia/Model/om/BaseTaxI18n.php deleted file mode 100755 index 0b9c8c565..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxI18n.php +++ /dev/null @@ -1,1077 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseTaxI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = TaxI18nPeer::ID; - } - - if ($this->aTax !== null && $this->aTax->getId() !== $v) { - $this->aTax = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = TaxI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = TaxI18nPeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return TaxI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = TaxI18nPeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 4; // 4 = TaxI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating TaxI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aTax !== null && $this->id !== $this->aTax->getId()) { - $this->aTax = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::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 = TaxI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aTax = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = TaxI18nQuery::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(TaxI18nPeer::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); - TaxI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTax !== null) { - if ($this->aTax->isModified() || $this->aTax->isNew()) { - $affectedRows += $this->aTax->save($con); - } - $this->setTax($this->aTax); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(TaxI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - if ($this->isColumnModified(TaxI18nPeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(TaxI18nPeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - - $sql = sprintf( - 'INSERT INTO `tax_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - } - } - $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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTax !== null) { - if (!$this->aTax->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aTax->getValidationFailures()); - } - } - - - if (($retval = TaxI18nPeer::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 = TaxI18nPeer::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->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - 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['TaxI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['TaxI18n'][serialize($this->getPrimaryKey())] = true; - $keys = TaxI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - ); - if ($includeForeignObjects) { - if (null !== $this->aTax) { - $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxI18nPeer::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->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($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 = TaxI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - } - - /** - * 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(TaxI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(TaxI18nPeer::ID)) $criteria->add(TaxI18nPeer::ID, $this->id); - if ($this->isColumnModified(TaxI18nPeer::LOCALE)) $criteria->add(TaxI18nPeer::LOCALE, $this->locale); - if ($this->isColumnModified(TaxI18nPeer::TITLE)) $criteria->add(TaxI18nPeer::TITLE, $this->title); - if ($this->isColumnModified(TaxI18nPeer::DESCRIPTION)) $criteria->add(TaxI18nPeer::DESCRIPTION, $this->description); - - 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(TaxI18nPeer::DATABASE_NAME); - $criteria->add(TaxI18nPeer::ID, $this->id); - $criteria->add(TaxI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 TaxI18n (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->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - - 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 TaxI18n 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 TaxI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new TaxI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Tax object. - * - * @param Tax $v - * @return TaxI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setTax(Tax $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aTax = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Tax object, it will not be re-added. - if ($v !== null) { - $v->addTaxI18n($this); - } - - - return $this; - } - - - /** - * Get the associated Tax object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Tax The associated Tax object. - * @throws PropelException - */ - public function getTax(PropelPDO $con = null, $doQuery = true) - { - if ($this->aTax === null && ($this->id !== null) && $doQuery) { - $this->aTax = TaxQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aTax->addTaxI18ns($this); - */ - } - - return $this->aTax; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aTax instanceof Persistent) { - $this->aTax->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aTax = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(TaxI18nPeer::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/BaseTaxI18nPeer.php b/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php deleted file mode 100755 index f8f0b8bdc..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxI18nPeer.php +++ /dev/null @@ -1,1006 +0,0 @@ - array ('Id', 'Locale', 'Title', 'Description', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', 'title', 'description', ), - BasePeer::TYPE_COLNAME => array (TaxI18nPeer::ID, TaxI18nPeer::LOCALE, TaxI18nPeer::TITLE, TaxI18nPeer::DESCRIPTION, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', 'title', 'description', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. TaxI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ), - BasePeer::TYPE_COLNAME => array (TaxI18nPeer::ID => 0, TaxI18nPeer::LOCALE => 1, TaxI18nPeer::TITLE => 2, TaxI18nPeer::DESCRIPTION => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = TaxI18nPeer::getFieldNames($toType); - $key = isset(TaxI18nPeer::$fieldKeys[$fromType][$name]) ? TaxI18nPeer::$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(TaxI18nPeer::$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, TaxI18nPeer::$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 TaxI18nPeer::$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. TaxI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(TaxI18nPeer::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(TaxI18nPeer::ID); - $criteria->addSelectColumn(TaxI18nPeer::LOCALE); - $criteria->addSelectColumn(TaxI18nPeer::TITLE); - $criteria->addSelectColumn(TaxI18nPeer::DESCRIPTION); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - } - } - - /** - * 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(TaxI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(TaxI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::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 TaxI18n - * @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 = TaxI18nPeer::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 TaxI18nPeer::populateObjects(TaxI18nPeer::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 directly (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(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - TaxI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(TaxI18nPeer::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 TaxI18n $obj A TaxI18n 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->getLocale())); - } // if key === null - TaxI18nPeer::$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 TaxI18n 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 TaxI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 TaxI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(TaxI18nPeer::$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 TaxI18n 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(TaxI18nPeer::$instances[$key])) { - return TaxI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (TaxI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - TaxI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to tax_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = TaxI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = TaxI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = TaxI18nPeer::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; - TaxI18nPeer::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 (TaxI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = TaxI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = TaxI18nPeer::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 + TaxI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = TaxI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - TaxI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Tax table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinTax(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxI18nPeer::ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of TaxI18n objects pre-filled with their Tax objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxI18nPeer::DATABASE_NAME); - } - - TaxI18nPeer::addSelectColumns($criteria); - $startcol = TaxI18nPeer::NUM_HYDRATE_COLUMNS; - TaxPeer::addSelectColumns($criteria); - - $criteria->addJoin(TaxI18nPeer::ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = TaxI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (TaxI18n) to $obj2 (Tax) - $obj2->addTaxI18n($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(TaxI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxI18nPeer::ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of TaxI18n 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 TaxI18n 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(TaxI18nPeer::DATABASE_NAME); - } - - TaxI18nPeer::addSelectColumns($criteria); - $startcol2 = TaxI18nPeer::NUM_HYDRATE_COLUMNS; - - TaxPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxI18nPeer::ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Tax rows - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (TaxI18n) to the collection in $obj2 (Tax) - $obj2->addTaxI18n($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(TaxI18nPeer::DATABASE_NAME)->getTable(TaxI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseTaxI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseTaxI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new TaxI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return TaxI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a TaxI18n or Criteria object. - * - * @param mixed $values Criteria or TaxI18n 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(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from TaxI18n object - } - - - // Set the correct dbName - $criteria->setDbName(TaxI18nPeer::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 TaxI18n or Criteria object. - * - * @param mixed $values Criteria or TaxI18n 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(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(TaxI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(TaxI18nPeer::ID); - $value = $criteria->remove(TaxI18nPeer::ID); - if ($value) { - $selectCriteria->add(TaxI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(TaxI18nPeer::LOCALE); - $value = $criteria->remove(TaxI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(TaxI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxI18nPeer::TABLE_NAME); - } - - } else { // $values is TaxI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(TaxI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the tax_i18n 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(TaxI18nPeer::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(TaxI18nPeer::TABLE_NAME, $con, TaxI18nPeer::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). - TaxI18nPeer::clearInstancePool(); - TaxI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a TaxI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or TaxI18n 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(TaxI18nPeer::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. - TaxI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof TaxI18n) { // it's a model object - // invalidate the cache for this single object - TaxI18nPeer::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(TaxI18nPeer::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(TaxI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(TaxI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - TaxI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(TaxI18nPeer::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); - TaxI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given TaxI18n 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 TaxI18n $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(TaxI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(TaxI18nPeer::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(TaxI18nPeer::DATABASE_NAME, TaxI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return TaxI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = TaxI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(TaxI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(TaxI18nPeer::DATABASE_NAME); - $criteria->add(TaxI18nPeer::ID, $id); - $criteria->add(TaxI18nPeer::LOCALE, $locale); - $v = TaxI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseTaxI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseTaxI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php b/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php deleted file mode 100755 index 6d41da4e4..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxI18nQuery.php +++ /dev/null @@ -1,471 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return TaxI18n|TaxI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = TaxI18nPeer::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(TaxI18nPeer::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 TaxI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale`, `title`, `description` FROM `tax_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 TaxI18n(); - $obj->hydrate($row); - TaxI18nPeer::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 TaxI18n|TaxI18n[]|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|TaxI18n[]|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 TaxI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(TaxI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(TaxI18nPeer::LOCALE, $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 TaxI18nQuery 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(TaxI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(TaxI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByTax() - * - * @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 TaxI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(TaxI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(TaxI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 TaxI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxI18nPeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxI18nPeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query by a related Tax object - * - * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTax($tax, $comparison = null) - { - if ($tax instanceof Tax) { - return $this - ->addUsingAlias(TaxI18nPeer::ID, $tax->getId(), $comparison); - } elseif ($tax instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(TaxI18nPeer::ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Tax relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxI18nQuery The current query, for fluid interface - */ - public function joinTax($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Tax'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Tax'); - } - - return $this; - } - - /** - * Use the Tax relation Tax object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query - */ - public function useTaxQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinTax($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery'); - } - - /** - * Exclude object from result - * - * @param TaxI18n $taxI18n Object to remove from the list of results - * - * @return TaxI18nQuery The current query, for fluid interface - */ - public function prune($taxI18n = null) - { - if ($taxI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(TaxI18nPeer::ID), $taxI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(TaxI18nPeer::LOCALE), $taxI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxPeer.php b/core/lib/Thelia/Model/om/BaseTaxPeer.php deleted file mode 100755 index 2b694ae47..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxPeer.php +++ /dev/null @@ -1,800 +0,0 @@ - array ('Id', 'Rate', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'rate', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (TaxPeer::ID, TaxPeer::RATE, TaxPeer::CREATED_AT, TaxPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'RATE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'rate', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. TaxPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Rate' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'rate' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - BasePeer::TYPE_COLNAME => array (TaxPeer::ID => 0, TaxPeer::RATE => 1, TaxPeer::CREATED_AT => 2, TaxPeer::UPDATED_AT => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'RATE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'rate' => 1, 'created_at' => 2, 'updated_at' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = TaxPeer::getFieldNames($toType); - $key = isset(TaxPeer::$fieldKeys[$fromType][$name]) ? TaxPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, TaxPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return TaxPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. TaxPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(TaxPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(TaxPeer::ID); - $criteria->addSelectColumn(TaxPeer::RATE); - $criteria->addSelectColumn(TaxPeer::CREATED_AT); - $criteria->addSelectColumn(TaxPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.rate'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(TaxPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return Tax - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = TaxPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return TaxPeer::populateObjects(TaxPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - TaxPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(TaxPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param Tax $obj A Tax object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - TaxPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A Tax object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof Tax) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or Tax object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(TaxPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return Tax Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(TaxPeer::$instances[$key])) { - return TaxPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (TaxPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - TaxPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to tax - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in TaxRuleCountryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxRuleCountryPeer::clearInstancePool(); - // Invalidate objects in TaxI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = TaxPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = TaxPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = TaxPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - TaxPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Tax object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = TaxPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + TaxPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = TaxPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - TaxPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(TaxPeer::DATABASE_NAME)->getTable(TaxPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseTaxPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseTaxPeer::TABLE_NAME)) { - $dbMap->addTableObject(new TaxTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return TaxPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a Tax or Criteria object. - * - * @param mixed $values Criteria or Tax object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from Tax object - } - - if ($criteria->containsKey(TaxPeer::ID) && $criteria->keyContainsValue(TaxPeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxPeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(TaxPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a Tax or Criteria object. - * - * @param mixed $values Criteria or Tax object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(TaxPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(TaxPeer::ID); - $value = $criteria->remove(TaxPeer::ID); - if ($value) { - $selectCriteria->add(TaxPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxPeer::TABLE_NAME); - } - - } else { // $values is Tax object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(TaxPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the tax table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(TaxPeer::TABLE_NAME, $con, TaxPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - TaxPeer::clearInstancePool(); - TaxPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a Tax or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Tax object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - TaxPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof Tax) { // it's a model object - // invalidate the cache for this single object - TaxPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(TaxPeer::DATABASE_NAME); - $criteria->add(TaxPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - TaxPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(TaxPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - TaxPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given Tax object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param Tax $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(TaxPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(TaxPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(TaxPeer::DATABASE_NAME, TaxPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return Tax - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = TaxPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(TaxPeer::DATABASE_NAME); - $criteria->add(TaxPeer::ID, $pk); - - $v = TaxPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return Tax[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(TaxPeer::DATABASE_NAME); - $criteria->add(TaxPeer::ID, $pks, Criteria::IN); - $objs = TaxPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseTaxPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseTaxPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseTaxQuery.php b/core/lib/Thelia/Model/om/BaseTaxQuery.php deleted file mode 100755 index 5149f7e81..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxQuery.php +++ /dev/null @@ -1,707 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return Tax|Tax[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = TaxPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(TaxPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Tax A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Tax A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `rate`, `created_at`, `updated_at` FROM `tax` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new Tax(); - $obj->hydrate($row); - TaxPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return Tax|Tax[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|Tax[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(TaxPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(TaxPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(TaxPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(TaxPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the rate column - * - * Example usage: - * - * $query->filterByRate(1234); // WHERE rate = 1234 - * $query->filterByRate(array(12, 34)); // WHERE rate IN (12, 34) - * $query->filterByRate(array('min' => 12)); // WHERE rate >= 12 - * $query->filterByRate(array('max' => 12)); // WHERE rate <= 12 - * - * - * @param mixed $rate The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterByRate($rate = null, $comparison = null) - { - if (is_array($rate)) { - $useMinMax = false; - if (isset($rate['min'])) { - $this->addUsingAlias(TaxPeer::RATE, $rate['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($rate['max'])) { - $this->addUsingAlias(TaxPeer::RATE, $rate['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxPeer::RATE, $rate, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related TaxRuleCountry object - * - * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) - { - if ($taxRuleCountry instanceof TaxRuleCountry) { - return $this - ->addUsingAlias(TaxPeer::ID, $taxRuleCountry->getTaxId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { - return $this - ->useTaxRuleCountryQuery() - ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRuleCountry relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxQuery The current query, for fluid interface - */ - public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRuleCountry'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRuleCountry'); - } - - return $this; - } - - /** - * Use the TaxRuleCountry relation TaxRuleCountry object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRuleCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); - } - - /** - * Filter the query by a related TaxI18n object - * - * @param TaxI18n|PropelObjectCollection $taxI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxI18n($taxI18n, $comparison = null) - { - if ($taxI18n instanceof TaxI18n) { - return $this - ->addUsingAlias(TaxPeer::ID, $taxI18n->getId(), $comparison); - } elseif ($taxI18n instanceof PropelObjectCollection) { - return $this - ->useTaxI18nQuery() - ->filterByPrimaryKeys($taxI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxI18n() only accepts arguments of type TaxI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxQuery The current query, for fluid interface - */ - public function joinTaxI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxI18n'); - } - - return $this; - } - - /** - * Use the TaxI18n relation TaxI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxI18nQuery A secondary query class using the current class as primary query - */ - public function useTaxI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinTaxI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', '\Thelia\Model\TaxI18nQuery'); - } - - /** - * Exclude object from result - * - * @param Tax $tax Object to remove from the list of results - * - * @return TaxQuery The current query, for fluid interface - */ - public function prune($tax = null) - { - if ($tax) { - $this->addUsingAlias(TaxPeer::ID, $tax->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return TaxQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(TaxPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return TaxQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(TaxPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return TaxQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(TaxPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return TaxQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(TaxPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return TaxQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(TaxPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return TaxQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(TaxPeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; - - return $this - ->joinTaxI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('TaxI18n'); - $this->with['TaxI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxI18n', 'Thelia\Model\TaxI18nQuery'); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxRule.php b/core/lib/Thelia/Model/om/BaseTaxRule.php deleted file mode 100755 index 5c86263c1..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRule.php +++ /dev/null @@ -1,2185 +0,0 @@ -id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return TaxRule The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = TaxRulePeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = TaxRulePeer::CODE; - } - - - return $this; - } // setCode() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = TaxRulePeer::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return TaxRule The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = TaxRulePeer::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return TaxRule The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = TaxRulePeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return TaxRule The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->code = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->title = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->description = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; - $this->created_at = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; - $this->updated_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 6; // 6 = TaxRulePeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating TaxRule object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = TaxRulePeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collProducts = null; - - $this->collTaxRuleCountrys = null; - - $this->collTaxRuleI18ns = null; - - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = TaxRuleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(TaxRulePeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(TaxRulePeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - TaxRulePeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->productsScheduledForDeletion !== null) { - if (!$this->productsScheduledForDeletion->isEmpty()) { - foreach ($this->productsScheduledForDeletion as $product) { - // need to save related object because we set the relation to null - $product->save($con); - } - $this->productsScheduledForDeletion = null; - } - } - - if ($this->collProducts !== null) { - foreach ($this->collProducts as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->taxRuleCountrysScheduledForDeletion !== null) { - if (!$this->taxRuleCountrysScheduledForDeletion->isEmpty()) { - foreach ($this->taxRuleCountrysScheduledForDeletion as $taxRuleCountry) { - // need to save related object because we set the relation to null - $taxRuleCountry->save($con); - } - $this->taxRuleCountrysScheduledForDeletion = null; - } - } - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->taxRuleI18nsScheduledForDeletion !== null) { - if (!$this->taxRuleI18nsScheduledForDeletion->isEmpty()) { - TaxRuleI18nQuery::create() - ->filterByPrimaryKeys($this->taxRuleI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->taxRuleI18nsScheduledForDeletion = null; - } - } - - if ($this->collTaxRuleI18ns !== null) { - foreach ($this->collTaxRuleI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = TaxRulePeer::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . TaxRulePeer::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxRulePeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(TaxRulePeer::CODE)) { - $modifiedColumns[':p' . $index++] = '`code`'; - } - if ($this->isColumnModified(TaxRulePeer::TITLE)) { - $modifiedColumns[':p' . $index++] = '`title`'; - } - if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = '`description`'; - } - if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `tax_rule` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`code`': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case '`title`': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case '`description`': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - if (($retval = TaxRulePeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - if ($this->collProducts !== null) { - foreach ($this->collProducts as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collTaxRuleCountrys !== null) { - foreach ($this->collTaxRuleCountrys as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - if ($this->collTaxRuleI18ns !== null) { - foreach ($this->collTaxRuleI18ns as $referrerFK) { - if (!$referrerFK->validate($columns)) { - $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); - } - } - } - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['TaxRule'][$this->getPrimaryKey()] = true; - $keys = TaxRulePeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->collProducts) { - $result['Products'] = $this->collProducts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collTaxRuleCountrys) { - $result['TaxRuleCountrys'] = $this->collTaxRuleCountrys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collTaxRuleI18ns) { - $result['TaxRuleI18ns'] = $this->collTaxRuleI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxRulePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = TaxRulePeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - - if ($this->isColumnModified(TaxRulePeer::ID)) $criteria->add(TaxRulePeer::ID, $this->id); - if ($this->isColumnModified(TaxRulePeer::CODE)) $criteria->add(TaxRulePeer::CODE, $this->code); - if ($this->isColumnModified(TaxRulePeer::TITLE)) $criteria->add(TaxRulePeer::TITLE, $this->title); - if ($this->isColumnModified(TaxRulePeer::DESCRIPTION)) $criteria->add(TaxRulePeer::DESCRIPTION, $this->description); - if ($this->isColumnModified(TaxRulePeer::CREATED_AT)) $criteria->add(TaxRulePeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(TaxRulePeer::UPDATED_AT)) $criteria->add(TaxRulePeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - $criteria->add(TaxRulePeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of TaxRule (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - foreach ($this->getProducts() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addProduct($relObj->copy($deepCopy)); - } - } - - foreach ($this->getTaxRuleCountrys() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxRuleCountry($relObj->copy($deepCopy)); - } - } - - foreach ($this->getTaxRuleI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addTaxRuleI18n($relObj->copy($deepCopy)); - } - } - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return TaxRule Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return TaxRulePeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new TaxRulePeer(); - } - - return self::$peer; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('Product' == $relationName) { - $this->initProducts(); - } - if ('TaxRuleCountry' == $relationName) { - $this->initTaxRuleCountrys(); - } - if ('TaxRuleI18n' == $relationName) { - $this->initTaxRuleI18ns(); - } - } - - /** - * Clears out the collProducts collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return TaxRule The current object (for fluent API support) - * @see addProducts() - */ - public function clearProducts() - { - $this->collProducts = null; // important to set this to null since that means it is uninitialized - $this->collProductsPartial = null; - - return $this; - } - - /** - * reset is the collProducts collection loaded partially - * - * @return void - */ - public function resetPartialProducts($v = true) - { - $this->collProductsPartial = $v; - } - - /** - * Initializes the collProducts collection. - * - * By default this just sets the collProducts collection to an empty array (like clearcollProducts()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initProducts($overrideExisting = true) - { - if (null !== $this->collProducts && !$overrideExisting) { - return; - } - $this->collProducts = new PropelObjectCollection(); - $this->collProducts->setModel('Product'); - } - - /** - * Gets an array of Product objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this TaxRule is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|Product[] List of Product objects - * @throws PropelException - */ - public function getProducts($criteria = null, PropelPDO $con = null) - { - $partial = $this->collProductsPartial && !$this->isNew(); - if (null === $this->collProducts || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProducts) { - // return empty collection - $this->initProducts(); - } else { - $collProducts = ProductQuery::create(null, $criteria) - ->filterByTaxRule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collProductsPartial && count($collProducts)) { - $this->initProducts(false); - - foreach($collProducts as $obj) { - if (false == $this->collProducts->contains($obj)) { - $this->collProducts->append($obj); - } - } - - $this->collProductsPartial = true; - } - - $collProducts->getInternalIterator()->rewind(); - return $collProducts; - } - - if($partial && $this->collProducts) { - foreach($this->collProducts as $obj) { - if($obj->isNew()) { - $collProducts[] = $obj; - } - } - } - - $this->collProducts = $collProducts; - $this->collProductsPartial = false; - } - } - - return $this->collProducts; - } - - /** - * Sets a collection of Product objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $products A Propel collection. - * @param PropelPDO $con Optional connection object - * @return TaxRule The current object (for fluent API support) - */ - public function setProducts(PropelCollection $products, PropelPDO $con = null) - { - $productsToDelete = $this->getProducts(new Criteria(), $con)->diff($products); - - $this->productsScheduledForDeletion = unserialize(serialize($productsToDelete)); - - foreach ($productsToDelete as $productRemoved) { - $productRemoved->setTaxRule(null); - } - - $this->collProducts = null; - foreach ($products as $product) { - $this->addProduct($product); - } - - $this->collProducts = $products; - $this->collProductsPartial = false; - - return $this; - } - - /** - * Returns the number of related Product objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related Product objects. - * @throws PropelException - */ - public function countProducts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collProductsPartial && !$this->isNew(); - if (null === $this->collProducts || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collProducts) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getProducts()); - } - $query = ProductQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); - } - - return count($this->collProducts); - } - - /** - * Method called to associate a Product object to this object - * through the Product foreign key attribute. - * - * @param Product $l Product - * @return TaxRule The current object (for fluent API support) - */ - public function addProduct(Product $l) - { - if ($this->collProducts === null) { - $this->initProducts(); - $this->collProductsPartial = true; - } - if (!in_array($l, $this->collProducts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddProduct($l); - } - - return $this; - } - - /** - * @param Product $product The product object to add. - */ - protected function doAddProduct($product) - { - $this->collProducts[]= $product; - $product->setTaxRule($this); - } - - /** - * @param Product $product The product object to remove. - * @return TaxRule The current object (for fluent API support) - */ - public function removeProduct($product) - { - if ($this->getProducts()->contains($product)) { - $this->collProducts->remove($this->collProducts->search($product)); - if (null === $this->productsScheduledForDeletion) { - $this->productsScheduledForDeletion = clone $this->collProducts; - $this->productsScheduledForDeletion->clear(); - } - $this->productsScheduledForDeletion[]= $product; - $product->setTaxRule(null); - } - - return $this; - } - - /** - * Clears out the collTaxRuleCountrys collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return TaxRule The current object (for fluent API support) - * @see addTaxRuleCountrys() - */ - public function clearTaxRuleCountrys() - { - $this->collTaxRuleCountrys = null; // important to set this to null since that means it is uninitialized - $this->collTaxRuleCountrysPartial = null; - - return $this; - } - - /** - * reset is the collTaxRuleCountrys collection loaded partially - * - * @return void - */ - public function resetPartialTaxRuleCountrys($v = true) - { - $this->collTaxRuleCountrysPartial = $v; - } - - /** - * Initializes the collTaxRuleCountrys collection. - * - * By default this just sets the collTaxRuleCountrys collection to an empty array (like clearcollTaxRuleCountrys()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initTaxRuleCountrys($overrideExisting = true) - { - if (null !== $this->collTaxRuleCountrys && !$overrideExisting) { - return; - } - $this->collTaxRuleCountrys = new PropelObjectCollection(); - $this->collTaxRuleCountrys->setModel('TaxRuleCountry'); - } - - /** - * Gets an array of TaxRuleCountry objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this TaxRule is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - * @throws PropelException - */ - public function getTaxRuleCountrys($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - // return empty collection - $this->initTaxRuleCountrys(); - } else { - $collTaxRuleCountrys = TaxRuleCountryQuery::create(null, $criteria) - ->filterByTaxRule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxRuleCountrysPartial && count($collTaxRuleCountrys)) { - $this->initTaxRuleCountrys(false); - - foreach($collTaxRuleCountrys as $obj) { - if (false == $this->collTaxRuleCountrys->contains($obj)) { - $this->collTaxRuleCountrys->append($obj); - } - } - - $this->collTaxRuleCountrysPartial = true; - } - - $collTaxRuleCountrys->getInternalIterator()->rewind(); - return $collTaxRuleCountrys; - } - - if($partial && $this->collTaxRuleCountrys) { - foreach($this->collTaxRuleCountrys as $obj) { - if($obj->isNew()) { - $collTaxRuleCountrys[] = $obj; - } - } - } - - $this->collTaxRuleCountrys = $collTaxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - } - } - - return $this->collTaxRuleCountrys; - } - - /** - * Sets a collection of TaxRuleCountry objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param PropelCollection $taxRuleCountrys A Propel collection. - * @param PropelPDO $con Optional connection object - * @return TaxRule The current object (for fluent API support) - */ - public function setTaxRuleCountrys(PropelCollection $taxRuleCountrys, PropelPDO $con = null) - { - $taxRuleCountrysToDelete = $this->getTaxRuleCountrys(new Criteria(), $con)->diff($taxRuleCountrys); - - $this->taxRuleCountrysScheduledForDeletion = unserialize(serialize($taxRuleCountrysToDelete)); - - foreach ($taxRuleCountrysToDelete as $taxRuleCountryRemoved) { - $taxRuleCountryRemoved->setTaxRule(null); - } - - $this->collTaxRuleCountrys = null; - foreach ($taxRuleCountrys as $taxRuleCountry) { - $this->addTaxRuleCountry($taxRuleCountry); - } - - $this->collTaxRuleCountrys = $taxRuleCountrys; - $this->collTaxRuleCountrysPartial = false; - - return $this; - } - - /** - * Returns the number of related TaxRuleCountry objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxRuleCountry objects. - * @throws PropelException - */ - public function countTaxRuleCountrys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxRuleCountrysPartial && !$this->isNew(); - if (null === $this->collTaxRuleCountrys || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleCountrys) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getTaxRuleCountrys()); - } - $query = TaxRuleCountryQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); - } - - return count($this->collTaxRuleCountrys); - } - - /** - * Method called to associate a TaxRuleCountry object to this object - * through the TaxRuleCountry foreign key attribute. - * - * @param TaxRuleCountry $l TaxRuleCountry - * @return TaxRule The current object (for fluent API support) - */ - public function addTaxRuleCountry(TaxRuleCountry $l) - { - if ($this->collTaxRuleCountrys === null) { - $this->initTaxRuleCountrys(); - $this->collTaxRuleCountrysPartial = true; - } - if (!in_array($l, $this->collTaxRuleCountrys->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddTaxRuleCountry($l); - } - - return $this; - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to add. - */ - protected function doAddTaxRuleCountry($taxRuleCountry) - { - $this->collTaxRuleCountrys[]= $taxRuleCountry; - $taxRuleCountry->setTaxRule($this); - } - - /** - * @param TaxRuleCountry $taxRuleCountry The taxRuleCountry object to remove. - * @return TaxRule The current object (for fluent API support) - */ - public function removeTaxRuleCountry($taxRuleCountry) - { - if ($this->getTaxRuleCountrys()->contains($taxRuleCountry)) { - $this->collTaxRuleCountrys->remove($this->collTaxRuleCountrys->search($taxRuleCountry)); - if (null === $this->taxRuleCountrysScheduledForDeletion) { - $this->taxRuleCountrysScheduledForDeletion = clone $this->collTaxRuleCountrys; - $this->taxRuleCountrysScheduledForDeletion->clear(); - } - $this->taxRuleCountrysScheduledForDeletion[]= $taxRuleCountry; - $taxRuleCountry->setTaxRule(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this TaxRule is new, it will return - * an empty collection; or if this TaxRule has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in TaxRule. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinTax($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Tax', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this TaxRule is new, it will return - * an empty collection; or if this TaxRule has previously - * been saved, it will retrieve related TaxRuleCountrys from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in TaxRule. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return PropelObjectCollection|TaxRuleCountry[] List of TaxRuleCountry objects - */ - public function getTaxRuleCountrysJoinCountry($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $query = TaxRuleCountryQuery::create(null, $criteria); - $query->joinWith('Country', $join_behavior); - - return $this->getTaxRuleCountrys($query, $con); - } - - /** - * Clears out the collTaxRuleI18ns 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 TaxRule The current object (for fluent API support) - * @see addTaxRuleI18ns() - */ - public function clearTaxRuleI18ns() - { - $this->collTaxRuleI18ns = null; // important to set this to null since that means it is uninitialized - $this->collTaxRuleI18nsPartial = null; - - return $this; - } - - /** - * reset is the collTaxRuleI18ns collection loaded partially - * - * @return void - */ - public function resetPartialTaxRuleI18ns($v = true) - { - $this->collTaxRuleI18nsPartial = $v; - } - - /** - * Initializes the collTaxRuleI18ns collection. - * - * By default this just sets the collTaxRuleI18ns collection to an empty array (like clearcollTaxRuleI18ns()); - * 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 initTaxRuleI18ns($overrideExisting = true) - { - if (null !== $this->collTaxRuleI18ns && !$overrideExisting) { - return; - } - $this->collTaxRuleI18ns = new PropelObjectCollection(); - $this->collTaxRuleI18ns->setModel('TaxRuleI18n'); - } - - /** - * Gets an array of TaxRuleI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this TaxRule is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param PropelPDO $con optional connection object - * @return PropelObjectCollection|TaxRuleI18n[] List of TaxRuleI18n objects - * @throws PropelException - */ - public function getTaxRuleI18ns($criteria = null, PropelPDO $con = null) - { - $partial = $this->collTaxRuleI18nsPartial && !$this->isNew(); - if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleI18ns) { - // return empty collection - $this->initTaxRuleI18ns(); - } else { - $collTaxRuleI18ns = TaxRuleI18nQuery::create(null, $criteria) - ->filterByTaxRule($this) - ->find($con); - if (null !== $criteria) { - if (false !== $this->collTaxRuleI18nsPartial && count($collTaxRuleI18ns)) { - $this->initTaxRuleI18ns(false); - - foreach($collTaxRuleI18ns as $obj) { - if (false == $this->collTaxRuleI18ns->contains($obj)) { - $this->collTaxRuleI18ns->append($obj); - } - } - - $this->collTaxRuleI18nsPartial = true; - } - - $collTaxRuleI18ns->getInternalIterator()->rewind(); - return $collTaxRuleI18ns; - } - - if($partial && $this->collTaxRuleI18ns) { - foreach($this->collTaxRuleI18ns as $obj) { - if($obj->isNew()) { - $collTaxRuleI18ns[] = $obj; - } - } - } - - $this->collTaxRuleI18ns = $collTaxRuleI18ns; - $this->collTaxRuleI18nsPartial = false; - } - } - - return $this->collTaxRuleI18ns; - } - - /** - * Sets a collection of TaxRuleI18n 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 $taxRuleI18ns A Propel collection. - * @param PropelPDO $con Optional connection object - * @return TaxRule The current object (for fluent API support) - */ - public function setTaxRuleI18ns(PropelCollection $taxRuleI18ns, PropelPDO $con = null) - { - $taxRuleI18nsToDelete = $this->getTaxRuleI18ns(new Criteria(), $con)->diff($taxRuleI18ns); - - $this->taxRuleI18nsScheduledForDeletion = unserialize(serialize($taxRuleI18nsToDelete)); - - foreach ($taxRuleI18nsToDelete as $taxRuleI18nRemoved) { - $taxRuleI18nRemoved->setTaxRule(null); - } - - $this->collTaxRuleI18ns = null; - foreach ($taxRuleI18ns as $taxRuleI18n) { - $this->addTaxRuleI18n($taxRuleI18n); - } - - $this->collTaxRuleI18ns = $taxRuleI18ns; - $this->collTaxRuleI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related TaxRuleI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param PropelPDO $con - * @return int Count of related TaxRuleI18n objects. - * @throws PropelException - */ - public function countTaxRuleI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) - { - $partial = $this->collTaxRuleI18nsPartial && !$this->isNew(); - if (null === $this->collTaxRuleI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collTaxRuleI18ns) { - return 0; - } - - if($partial && !$criteria) { - return count($this->getTaxRuleI18ns()); - } - $query = TaxRuleI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByTaxRule($this) - ->count($con); - } - - return count($this->collTaxRuleI18ns); - } - - /** - * Method called to associate a TaxRuleI18n object to this object - * through the TaxRuleI18n foreign key attribute. - * - * @param TaxRuleI18n $l TaxRuleI18n - * @return TaxRule The current object (for fluent API support) - */ - public function addTaxRuleI18n(TaxRuleI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collTaxRuleI18ns === null) { - $this->initTaxRuleI18ns(); - $this->collTaxRuleI18nsPartial = true; - } - if (!in_array($l, $this->collTaxRuleI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddTaxRuleI18n($l); - } - - return $this; - } - - /** - * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to add. - */ - protected function doAddTaxRuleI18n($taxRuleI18n) - { - $this->collTaxRuleI18ns[]= $taxRuleI18n; - $taxRuleI18n->setTaxRule($this); - } - - /** - * @param TaxRuleI18n $taxRuleI18n The taxRuleI18n object to remove. - * @return TaxRule The current object (for fluent API support) - */ - public function removeTaxRuleI18n($taxRuleI18n) - { - if ($this->getTaxRuleI18ns()->contains($taxRuleI18n)) { - $this->collTaxRuleI18ns->remove($this->collTaxRuleI18ns->search($taxRuleI18n)); - if (null === $this->taxRuleI18nsScheduledForDeletion) { - $this->taxRuleI18nsScheduledForDeletion = clone $this->collTaxRuleI18ns; - $this->taxRuleI18nsScheduledForDeletion->clear(); - } - $this->taxRuleI18nsScheduledForDeletion[]= clone $taxRuleI18n; - $taxRuleI18n->setTaxRule(null); - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->title = null; - $this->description = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->collProducts) { - foreach ($this->collProducts as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collTaxRuleCountrys) { - foreach ($this->collTaxRuleCountrys as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collTaxRuleI18ns) { - foreach ($this->collTaxRuleI18ns as $o) { - $o->clearAllReferences($deep); - } - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collProducts instanceof PropelCollection) { - $this->collProducts->clearIterator(); - } - $this->collProducts = null; - if ($this->collTaxRuleCountrys instanceof PropelCollection) { - $this->collTaxRuleCountrys->clearIterator(); - } - $this->collTaxRuleCountrys = null; - if ($this->collTaxRuleI18ns instanceof PropelCollection) { - $this->collTaxRuleI18ns->clearIterator(); - } - $this->collTaxRuleI18ns = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(TaxRulePeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return TaxRule The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = TaxRulePeer::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return TaxRule The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return TaxRuleI18n */ - public function getTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collTaxRuleI18ns) { - foreach ($this->collTaxRuleI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new TaxRuleI18n(); - $translation->setLocale($locale); - } else { - $translation = TaxRuleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addTaxRuleI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param PropelPDO $con an optional connection object - * - * @return TaxRule The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', PropelPDO $con = null) - { - if (!$this->isNew()) { - TaxRuleI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collTaxRuleI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collTaxRuleI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param PropelPDO $con an optional connection object - * - * @return TaxRuleI18n */ - public function getCurrentTranslation(PropelPDO $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php deleted file mode 100755 index 9f60627f2..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountry.php +++ /dev/null @@ -1,1473 +0,0 @@ -id; - } - - /** - * Get the [tax_rule_id] column value. - * - * @return int - */ - public function getTaxRuleId() - { - return $this->tax_rule_id; - } - - /** - * Get the [country_id] column value. - * - * @return int - */ - public function getCountryId() - { - return $this->country_id; - } - - /** - * Get the [tax_id] column value. - * - * @return int - */ - public function getTaxId() - { - return $this->tax_id; - } - - /** - * Get the [none] column value. - * - * @return int - */ - public function getNone() - { - return $this->none; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is null, then the raw DateTime object will be returned. - * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = 'Y-m-d H:i:s') - { - if ($this->created_at === null) { - return null; - } - - if ($this->created_at === '0000-00-00 00:00:00') { - // while technically this is not a default value of null, - // this seems to be closest in meaning. - return null; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - 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; - } - - 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; - } - - if (strpos($format, '%') !== false) { - return strftime($format, $dt->format('U')); - } - - return $dt->format($format); - - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = TaxRuleCountryPeer::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [tax_rule_id] column. - * - * @param int $v new value - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setTaxRuleId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->tax_rule_id !== $v) { - $this->tax_rule_id = $v; - $this->modifiedColumns[] = TaxRuleCountryPeer::TAX_RULE_ID; - } - - if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) { - $this->aTaxRule = null; - } - - - return $this; - } // setTaxRuleId() - - /** - * Set the value of [country_id] column. - * - * @param int $v new value - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setCountryId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->country_id !== $v) { - $this->country_id = $v; - $this->modifiedColumns[] = TaxRuleCountryPeer::COUNTRY_ID; - } - - if ($this->aCountry !== null && $this->aCountry->getId() !== $v) { - $this->aCountry = null; - } - - - return $this; - } // setCountryId() - - /** - * Set the value of [tax_id] column. - * - * @param int $v new value - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setTaxId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->tax_id !== $v) { - $this->tax_id = $v; - $this->modifiedColumns[] = TaxRuleCountryPeer::TAX_ID; - } - - if ($this->aTax !== null && $this->aTax->getId() !== $v) { - $this->aTax = null; - } - - - return $this; - } // setTaxId() - - /** - * Set the value of [none] column. - * - * @param int $v new value - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setNone($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->none !== $v) { - $this->none = $v; - $this->modifiedColumns[] = TaxRuleCountryPeer::NONE; - } - - - return $this; - } // setNone() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->created_at !== null || $dt !== null) { - $currentDateAsString = ($this->created_at !== null && $tmpDt = new DateTime($this->created_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->created_at = $newDateAsString; - $this->modifiedColumns[] = TaxRuleCountryPeer::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or DateTime value. - * Empty strings are treated as null. - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); - if ($this->updated_at !== null || $dt !== null) { - $currentDateAsString = ($this->updated_at !== null && $tmpDt = new DateTime($this->updated_at)) ? $tmpDt->format('Y-m-d H:i:s') : null; - $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; - if ($currentDateAsString !== $newDateAsString) { - $this->updated_at = $newDateAsString; - $this->modifiedColumns[] = TaxRuleCountryPeer::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return true - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false) - { - try { - - $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; - $this->tax_rule_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null; - $this->country_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; - $this->tax_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; - $this->none = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null; - $this->created_at = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; - $this->updated_at = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 7; // 7 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating TaxRuleCountry object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aTaxRule !== null && $this->tax_rule_id !== $this->aTaxRule->getId()) { - $this->aTaxRule = null; - } - if ($this->aCountry !== null && $this->country_id !== $this->aCountry->getId()) { - $this->aCountry = null; - } - if ($this->aTax !== null && $this->tax_id !== $this->aTax->getId()) { - $this->aTax = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $stmt = TaxRuleCountryPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aTax = null; - $this->aTaxRule = null; - $this->aCountry = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = TaxRuleCountryQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @throws Exception - * @see doSave() - */ - public function save(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - TaxRuleCountryPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTax !== null) { - if ($this->aTax->isModified() || $this->aTax->isNew()) { - $affectedRows += $this->aTax->save($con); - } - $this->setTax($this->aTax); - } - - if ($this->aTaxRule !== null) { - if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) { - $affectedRows += $this->aTaxRule->save($con); - } - $this->setTaxRule($this->aTaxRule); - } - - if ($this->aCountry !== null) { - if ($this->aCountry->isModified() || $this->aCountry->isNew()) { - $affectedRows += $this->aCountry->save($con); - } - $this->setCountry($this->aCountry); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxRuleCountryPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::TAX_RULE_ID)) { - $modifiedColumns[':p' . $index++] = '`tax_rule_id`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::COUNTRY_ID)) { - $modifiedColumns[':p' . $index++] = '`country_id`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::TAX_ID)) { - $modifiedColumns[':p' . $index++] = '`tax_id`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::NONE)) { - $modifiedColumns[':p' . $index++] = '`none`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = '`created_at`'; - } - if ($this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = '`updated_at`'; - } - - $sql = sprintf( - 'INSERT INTO `tax_rule_country` (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case '`id`': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case '`tax_rule_id`': - $stmt->bindValue($identifier, $this->tax_rule_id, PDO::PARAM_INT); - break; - case '`country_id`': - $stmt->bindValue($identifier, $this->country_id, PDO::PARAM_INT); - break; - case '`tax_id`': - $stmt->bindValue($identifier, $this->tax_id, PDO::PARAM_INT); - break; - case '`none`': - $stmt->bindValue($identifier, $this->none, PDO::PARAM_INT); - break; - case '`created_at`': - $stmt->bindValue($identifier, $this->created_at, PDO::PARAM_STR); - break; - case '`updated_at`': - $stmt->bindValue($identifier, $this->updated_at, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param PropelPDO $con - * - * @see doSave() - */ - protected function doUpdate(PropelPDO $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con); - } - - /** - * Array of ValidationFailed objects. - * @var array ValidationFailed[] - */ - protected $validationFailures = array(); - - /** - * Gets any ValidationFailed objects that resulted from last call to validate(). - * - * - * @return array ValidationFailed[] - * @see validate() - */ - public function getValidationFailures() - { - return $this->validationFailures; - } - - /** - * Validates the objects modified field values and all objects related to this table. - * - * If $columns is either a column name or an array of column names - * only those columns are validated. - * - * @param mixed $columns Column name or an array of column names. - * @return boolean Whether all columns pass validation. - * @see doValidate() - * @see getValidationFailures() - */ - public function validate($columns = null) - { - $res = $this->doValidate($columns); - if ($res === true) { - $this->validationFailures = array(); - - return true; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTax !== null) { - if (!$this->aTax->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aTax->getValidationFailures()); - } - } - - if ($this->aTaxRule !== null) { - if (!$this->aTaxRule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures()); - } - } - - if ($this->aCountry !== null) { - if (!$this->aCountry->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aCountry->getValidationFailures()); - } - } - - - if (($retval = TaxRuleCountryPeer::doValidate($this, $columns)) !== true) { - $failureMap = array_merge($failureMap, $retval); - } - - - - $this->alreadyInValidation = false; - } - - return (!empty($failureMap) ? $failureMap : true); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return mixed Value of field. - */ - public function getByName($name, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxRuleCountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getTaxRuleId(); - break; - case 2: - return $this->getCountryId(); - break; - case 3: - return $this->getTaxId(); - break; - case 4: - return $this->getNone(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['TaxRuleCountry'][$this->getPrimaryKey()] = true; - $keys = TaxRuleCountryPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getTaxRuleId(), - $keys[2] => $this->getCountryId(), - $keys[3] => $this->getTaxId(), - $keys[4] => $this->getNone(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - if ($includeForeignObjects) { - if (null !== $this->aTax) { - $result['Tax'] = $this->aTax->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aTaxRule) { - $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aCountry) { - $result['Country'] = $this->aCountry->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxRuleCountryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); - - $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setTaxRuleId($value); - break; - case 2: - $this->setCountryId($value); - break; - case 3: - $this->setTaxId($value); - break; - case 4: - $this->setNone($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * The default key type is the column's BasePeer::TYPE_PHPNAME - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) - { - $keys = TaxRuleCountryPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setTaxRuleId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCountryId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setTaxId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setNone($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - - if ($this->isColumnModified(TaxRuleCountryPeer::ID)) $criteria->add(TaxRuleCountryPeer::ID, $this->id); - if ($this->isColumnModified(TaxRuleCountryPeer::TAX_RULE_ID)) $criteria->add(TaxRuleCountryPeer::TAX_RULE_ID, $this->tax_rule_id); - if ($this->isColumnModified(TaxRuleCountryPeer::COUNTRY_ID)) $criteria->add(TaxRuleCountryPeer::COUNTRY_ID, $this->country_id); - if ($this->isColumnModified(TaxRuleCountryPeer::TAX_ID)) $criteria->add(TaxRuleCountryPeer::TAX_ID, $this->tax_id); - if ($this->isColumnModified(TaxRuleCountryPeer::NONE)) $criteria->add(TaxRuleCountryPeer::NONE, $this->none); - if ($this->isColumnModified(TaxRuleCountryPeer::CREATED_AT)) $criteria->add(TaxRuleCountryPeer::CREATED_AT, $this->created_at); - if ($this->isColumnModified(TaxRuleCountryPeer::UPDATED_AT)) $criteria->add(TaxRuleCountryPeer::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - $criteria->add(TaxRuleCountryPeer::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of TaxRuleCountry (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setTaxRuleId($this->getTaxRuleId()); - $copyObj->setCountryId($this->getCountryId()); - $copyObj->setTaxId($this->getTaxId()); - $copyObj->setNone($this->getNone()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy && !$this->startCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - // store object hash to prevent cycle - $this->startCopy = true; - - //unflag object copy - $this->startCopy = false; - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return TaxRuleCountry Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Returns a peer instance associated with this om. - * - * Since Peer classes are not to have any instance attributes, this method returns the - * same instance for all member of this class. The method could therefore - * be static, but this would prevent one from overriding the behavior. - * - * @return TaxRuleCountryPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new TaxRuleCountryPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a Tax object. - * - * @param Tax $v - * @return TaxRuleCountry The current object (for fluent API support) - * @throws PropelException - */ - public function setTax(Tax $v = null) - { - if ($v === null) { - $this->setTaxId(NULL); - } else { - $this->setTaxId($v->getId()); - } - - $this->aTax = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Tax object, it will not be re-added. - if ($v !== null) { - $v->addTaxRuleCountry($this); - } - - - return $this; - } - - - /** - * Get the associated Tax object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Tax The associated Tax object. - * @throws PropelException - */ - public function getTax(PropelPDO $con = null, $doQuery = true) - { - if ($this->aTax === null && ($this->tax_id !== null) && $doQuery) { - $this->aTax = TaxQuery::create()->findPk($this->tax_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aTax->addTaxRuleCountrys($this); - */ - } - - return $this->aTax; - } - - /** - * Declares an association between this object and a TaxRule object. - * - * @param TaxRule $v - * @return TaxRuleCountry The current object (for fluent API support) - * @throws PropelException - */ - public function setTaxRule(TaxRule $v = null) - { - if ($v === null) { - $this->setTaxRuleId(NULL); - } else { - $this->setTaxRuleId($v->getId()); - } - - $this->aTaxRule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the TaxRule object, it will not be re-added. - if ($v !== null) { - $v->addTaxRuleCountry($this); - } - - - return $this; - } - - - /** - * Get the associated TaxRule object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return TaxRule The associated TaxRule object. - * @throws PropelException - */ - public function getTaxRule(PropelPDO $con = null, $doQuery = true) - { - if ($this->aTaxRule === null && ($this->tax_rule_id !== null) && $doQuery) { - $this->aTaxRule = TaxRuleQuery::create()->findPk($this->tax_rule_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aTaxRule->addTaxRuleCountrys($this); - */ - } - - return $this->aTaxRule; - } - - /** - * Declares an association between this object and a Country object. - * - * @param Country $v - * @return TaxRuleCountry The current object (for fluent API support) - * @throws PropelException - */ - public function setCountry(Country $v = null) - { - if ($v === null) { - $this->setCountryId(NULL); - } else { - $this->setCountryId($v->getId()); - } - - $this->aCountry = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the Country object, it will not be re-added. - if ($v !== null) { - $v->addTaxRuleCountry($this); - } - - - return $this; - } - - - /** - * Get the associated Country object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return Country The associated Country object. - * @throws PropelException - */ - public function getCountry(PropelPDO $con = null, $doQuery = true) - { - if ($this->aCountry === null && ($this->country_id !== null) && $doQuery) { - $this->aCountry = CountryQuery::create()->findPk($this->country_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aCountry->addTaxRuleCountrys($this); - */ - } - - return $this->aCountry; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->tax_rule_id = null; - $this->country_id = null; - $this->tax_id = null; - $this->none = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volumne/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aTax instanceof Persistent) { - $this->aTax->clearAllReferences($deep); - } - if ($this->aTaxRule instanceof Persistent) { - $this->aTaxRule->clearAllReferences($deep); - } - if ($this->aCountry instanceof Persistent) { - $this->aCountry->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aTax = null; - $this->aTaxRule = null; - $this->aCountry = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(TaxRuleCountryPeer::DEFAULT_STRING_FORMAT); - } - - /** - * return true is the object is in saving state - * - * @return boolean - */ - public function isAlreadyInSave() - { - return $this->alreadyInSave; - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return TaxRuleCountry The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = TaxRuleCountryPeer::UPDATED_AT; - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php deleted file mode 100755 index feb536176..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryPeer.php +++ /dev/null @@ -1,1776 +0,0 @@ - array ('Id', 'TaxRuleId', 'CountryId', 'TaxId', 'None', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'taxRuleId', 'countryId', 'taxId', 'none', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (TaxRuleCountryPeer::ID, TaxRuleCountryPeer::TAX_RULE_ID, TaxRuleCountryPeer::COUNTRY_ID, TaxRuleCountryPeer::TAX_ID, TaxRuleCountryPeer::NONE, TaxRuleCountryPeer::CREATED_AT, TaxRuleCountryPeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TAX_RULE_ID', 'COUNTRY_ID', 'TAX_ID', 'NONE', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'tax_rule_id', 'country_id', 'tax_id', 'none', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. TaxRuleCountryPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'TaxRuleId' => 1, 'CountryId' => 2, 'TaxId' => 3, 'None' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'taxRuleId' => 1, 'countryId' => 2, 'taxId' => 3, 'none' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - BasePeer::TYPE_COLNAME => array (TaxRuleCountryPeer::ID => 0, TaxRuleCountryPeer::TAX_RULE_ID => 1, TaxRuleCountryPeer::COUNTRY_ID => 2, TaxRuleCountryPeer::TAX_ID => 3, TaxRuleCountryPeer::NONE => 4, TaxRuleCountryPeer::CREATED_AT => 5, TaxRuleCountryPeer::UPDATED_AT => 6, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TAX_RULE_ID' => 1, 'COUNTRY_ID' => 2, 'TAX_ID' => 3, 'NONE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'tax_rule_id' => 1, 'country_id' => 2, 'tax_id' => 3, 'none' => 4, 'created_at' => 5, 'updated_at' => 6, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = TaxRuleCountryPeer::getFieldNames($toType); - $key = isset(TaxRuleCountryPeer::$fieldKeys[$fromType][$name]) ? TaxRuleCountryPeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxRuleCountryPeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, TaxRuleCountryPeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return TaxRuleCountryPeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. TaxRuleCountryPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(TaxRuleCountryPeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(TaxRuleCountryPeer::ID); - $criteria->addSelectColumn(TaxRuleCountryPeer::TAX_RULE_ID); - $criteria->addSelectColumn(TaxRuleCountryPeer::COUNTRY_ID); - $criteria->addSelectColumn(TaxRuleCountryPeer::TAX_ID); - $criteria->addSelectColumn(TaxRuleCountryPeer::NONE); - $criteria->addSelectColumn(TaxRuleCountryPeer::CREATED_AT); - $criteria->addSelectColumn(TaxRuleCountryPeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.tax_rule_id'); - $criteria->addSelectColumn($alias . '.country_id'); - $criteria->addSelectColumn($alias . '.tax_id'); - $criteria->addSelectColumn($alias . '.none'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return TaxRuleCountry - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = TaxRuleCountryPeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return TaxRuleCountryPeer::populateObjects(TaxRuleCountryPeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param TaxRuleCountry $obj A TaxRuleCountry object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - TaxRuleCountryPeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A TaxRuleCountry object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof TaxRuleCountry) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxRuleCountry object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(TaxRuleCountryPeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return TaxRuleCountry Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(TaxRuleCountryPeer::$instances[$key])) { - return TaxRuleCountryPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (TaxRuleCountryPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - TaxRuleCountryPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to tax_rule_country - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = TaxRuleCountryPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - TaxRuleCountryPeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (TaxRuleCountry object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = TaxRuleCountryPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - TaxRuleCountryPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related Tax table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinTax(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related TaxRule table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinTaxRule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Country table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinCountry(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with their Tax objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - TaxPeer::addSelectColumns($criteria); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to $obj2 (Tax) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with their TaxRule objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - TaxRulePeer::addSelectColumns($criteria); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to $obj2 (TaxRule) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with their Country objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - CountryPeer::addSelectColumns($criteria); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = CountryPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = CountryPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - CountryPeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to $obj2 (Country) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row was not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining all related tables - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAll(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with all related objects. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - - TaxPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS; - - TaxRulePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + TaxRulePeer::NUM_HYDRATE_COLUMNS; - - CountryPeer::addSelectColumns($criteria); - $startcol5 = $startcol4 + CountryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Tax rows - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax) - $obj2->addTaxRuleCountry($obj1); - } // if joined row not null - - // Add objects for joined TaxRule rows - - $key3 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = TaxRulePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = TaxRulePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - TaxRulePeer::addInstanceToPool($obj3, $key3); - } // if obj3 loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (TaxRule) - $obj3->addTaxRuleCountry($obj1); - } // if joined row not null - - // Add objects for joined Country rows - - $key4 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol4); - if ($key4 !== null) { - $obj4 = CountryPeer::getInstanceFromPool($key4); - if (!$obj4) { - - $cls = CountryPeer::getOMClass(); - - $obj4 = new $cls(); - $obj4->hydrate($row, $startcol4); - CountryPeer::addInstanceToPool($obj4, $key4); - } // if obj4 loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj4 (Country) - $obj4->addTaxRuleCountry($obj1); - } // if joined row not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Returns the number of rows matching criteria, joining the related Tax table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptTax(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related TaxRule table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptTaxRule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Returns the number of rows matching criteria, joining the related Country table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinAllExceptCountry(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleCountryPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY should not affect count - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except Tax. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptTax(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - - TaxRulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS; - - CountryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CountryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined TaxRule rows - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (TaxRule) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row is not null - - // Add objects for joined Country rows - - $key3 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CountryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CountryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CountryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (Country) - $obj3->addTaxRuleCountry($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except TaxRule. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - - TaxPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS; - - CountryPeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + CountryPeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::COUNTRY_ID, CountryPeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Tax rows - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row is not null - - // Add objects for joined Country rows - - $key3 = CountryPeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = CountryPeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = CountryPeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - CountryPeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (Country) - $obj3->addTaxRuleCountry($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - - /** - * Selects a collection of TaxRuleCountry objects pre-filled with all related objects except Country. - * - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleCountry objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinAllExceptCountry(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - // $criteria->getDbName() will return the same object if not set to another value - // so == check is okay and faster - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - } - - TaxRuleCountryPeer::addSelectColumns($criteria); - $startcol2 = TaxRuleCountryPeer::NUM_HYDRATE_COLUMNS; - - TaxPeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxPeer::NUM_HYDRATE_COLUMNS; - - TaxRulePeer::addSelectColumns($criteria); - $startcol4 = $startcol3 + TaxRulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxRuleCountryPeer::TAX_ID, TaxPeer::ID, $join_behavior); - - $criteria->addJoin(TaxRuleCountryPeer::TAX_RULE_ID, TaxRulePeer::ID, $join_behavior); - - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleCountryPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleCountryPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxRuleCountryPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined Tax rows - - $key2 = TaxPeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxPeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxPeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxPeer::addInstanceToPool($obj2, $key2); - } // if $obj2 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj2 (Tax) - $obj2->addTaxRuleCountry($obj1); - - } // if joined row is not null - - // Add objects for joined TaxRule rows - - $key3 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol3); - if ($key3 !== null) { - $obj3 = TaxRulePeer::getInstanceFromPool($key3); - if (!$obj3) { - - $cls = TaxRulePeer::getOMClass(); - - $obj3 = new $cls(); - $obj3->hydrate($row, $startcol3); - TaxRulePeer::addInstanceToPool($obj3, $key3); - } // if $obj3 already loaded - - // Add the $obj1 (TaxRuleCountry) to the collection in $obj3 (TaxRule) - $obj3->addTaxRuleCountry($obj1); - - } // if joined row is not null - - $results[] = $obj1; - } - $stmt->closeCursor(); - - return $results; - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(TaxRuleCountryPeer::DATABASE_NAME)->getTable(TaxRuleCountryPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseTaxRuleCountryPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseTaxRuleCountryPeer::TABLE_NAME)) { - $dbMap->addTableObject(new TaxRuleCountryTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return TaxRuleCountryPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a TaxRuleCountry or Criteria object. - * - * @param mixed $values Criteria or TaxRuleCountry object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from TaxRuleCountry object - } - - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a TaxRuleCountry or Criteria object. - * - * @param mixed $values Criteria or TaxRuleCountry object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(TaxRuleCountryPeer::ID); - $value = $criteria->remove(TaxRuleCountryPeer::ID); - if ($value) { - $selectCriteria->add(TaxRuleCountryPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxRuleCountryPeer::TABLE_NAME); - } - - } else { // $values is TaxRuleCountry object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the tax_rule_country table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(TaxRuleCountryPeer::TABLE_NAME, $con, TaxRuleCountryPeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - TaxRuleCountryPeer::clearInstancePool(); - TaxRuleCountryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a TaxRuleCountry or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or TaxRuleCountry object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - TaxRuleCountryPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof TaxRuleCountry) { // it's a model object - // invalidate the cache for this single object - TaxRuleCountryPeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - $criteria->add(TaxRuleCountryPeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - TaxRuleCountryPeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(TaxRuleCountryPeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - TaxRuleCountryPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given TaxRuleCountry object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param TaxRuleCountry $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(TaxRuleCountryPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(TaxRuleCountryPeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(TaxRuleCountryPeer::DATABASE_NAME, TaxRuleCountryPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return TaxRuleCountry - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - $criteria->add(TaxRuleCountryPeer::ID, $pk); - - $v = TaxRuleCountryPeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return TaxRuleCountry[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(TaxRuleCountryPeer::DATABASE_NAME); - $criteria->add(TaxRuleCountryPeer::ID, $pks, Criteria::IN); - $objs = TaxRuleCountryPeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseTaxRuleCountryPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseTaxRuleCountryPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php deleted file mode 100755 index c78697899..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleCountryQuery.php +++ /dev/null @@ -1,879 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = TaxRuleCountryPeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(TaxRuleCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRuleCountry A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRuleCountry A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `tax_rule_id`, `country_id`, `tax_id`, `none`, `created_at`, `updated_at` FROM `tax_rule_country` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new TaxRuleCountry(); - $obj->hydrate($row); - TaxRuleCountryPeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRuleCountry|TaxRuleCountry[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|TaxRuleCountry[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::ID, $id, $comparison); - } - - /** - * 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 - * $query->filterByTaxRuleId(array('max' => 12)); // WHERE tax_rule_id <= 12 - * - * - * @see filterByTaxRule() - * - * @param mixed $taxRuleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByTaxRuleId($taxRuleId = null, $comparison = null) - { - if (is_array($taxRuleId)) { - $useMinMax = false; - if (isset($taxRuleId['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($taxRuleId['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRuleId, $comparison); - } - - /** - * Filter the query on the country_id column - * - * Example usage: - * - * $query->filterByCountryId(1234); // WHERE country_id = 1234 - * $query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34) - * $query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12 - * $query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12 - * - * - * @see filterByCountry() - * - * @param mixed $countryId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByCountryId($countryId = null, $comparison = null) - { - if (is_array($countryId)) { - $useMinMax = false; - if (isset($countryId['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($countryId['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $countryId, $comparison); - } - - /** - * Filter the query on the tax_id column - * - * Example usage: - * - * $query->filterByTaxId(1234); // WHERE tax_id = 1234 - * $query->filterByTaxId(array(12, 34)); // WHERE tax_id IN (12, 34) - * $query->filterByTaxId(array('min' => 12)); // WHERE tax_id >= 12 - * $query->filterByTaxId(array('max' => 12)); // WHERE tax_id <= 12 - * - * - * @see filterByTax() - * - * @param mixed $taxId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByTaxId($taxId = null, $comparison = null) - { - if (is_array($taxId)) { - $useMinMax = false; - if (isset($taxId['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($taxId['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $taxId, $comparison); - } - - /** - * Filter the query on the none column - * - * Example usage: - * - * $query->filterByNone(1234); // WHERE none = 1234 - * $query->filterByNone(array(12, 34)); // WHERE none IN (12, 34) - * $query->filterByNone(array('min' => 12)); // WHERE none >= 12 - * $query->filterByNone(array('max' => 12)); // WHERE none <= 12 - * - * - * @param mixed $none The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByNone($none = null, $comparison = null) - { - if (is_array($none)) { - $useMinMax = false; - if (isset($none['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($none['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::NONE, $none, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Tax object - * - * @param Tax|PropelObjectCollection $tax The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTax($tax, $comparison = null) - { - if ($tax instanceof Tax) { - return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->getId(), $comparison); - } elseif ($tax instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_ID, $tax->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByTax() only accepts arguments of type Tax or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Tax relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function joinTax($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Tax'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Tax'); - } - - return $this; - } - - /** - * Use the Tax relation Tax object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxQuery A secondary query class using the current class as primary query - */ - public function useTaxQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTax($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Tax', '\Thelia\Model\TaxQuery'); - } - - /** - * Filter the query by a related TaxRule object - * - * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRule($taxRule, $comparison = null) - { - if ($taxRule instanceof TaxRule) { - return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->getId(), $comparison); - } elseif ($taxRule instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(TaxRuleCountryPeer::TAX_RULE_ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function joinTaxRule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRule'); - } - - return $this; - } - - /** - * Use the TaxRule relation TaxRule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery'); - } - - /** - * Filter the query by a related Country object - * - * @param Country|PropelObjectCollection $country The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleCountryQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByCountry($country, $comparison = null) - { - if ($country instanceof Country) { - return $this - ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->getId(), $comparison); - } elseif ($country instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(TaxRuleCountryPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Country relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function joinCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Country'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Country'); - } - - return $this; - } - - /** - * Use the Country relation Country object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\CountryQuery A secondary query class using the current class as primary query - */ - public function useCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Country', '\Thelia\Model\CountryQuery'); - } - - /** - * Exclude object from result - * - * @param TaxRuleCountry $taxRuleCountry Object to remove from the list of results - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function prune($taxRuleCountry = null) - { - if ($taxRuleCountry) { - $this->addUsingAlias(TaxRuleCountryPeer::ID, $taxRuleCountry->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(TaxRuleCountryPeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(TaxRuleCountryPeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(TaxRuleCountryPeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(TaxRuleCountryPeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return TaxRuleCountryQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(TaxRuleCountryPeer::CREATED_AT); - } -} diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php deleted file mode 100755 index 3396b673b..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18n.php +++ /dev/null @@ -1,967 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of BaseTaxRuleI18n 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 [locale] column value. - * - * @return string - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return TaxRuleI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = TaxRuleI18nPeer::ID; - } - - if ($this->aTaxRule !== null && $this->aTaxRule->getId() !== $v) { - $this->aTaxRule = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return TaxRuleI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null && is_numeric($v)) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = TaxRuleI18nPeer::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * 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->locale !== 'en_US') { - 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->locale = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - $this->postHydrate($row, $startcol, $rehydrate); - return $startcol + 2; // 2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating TaxRuleI18n object", $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - - if ($this->aTaxRule !== null && $this->id !== $this->aTaxRule->getId()) { - $this->aTaxRule = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param PropelPDO $con (optional) The PropelPDO connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::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 = TaxRuleI18nPeer::doSelectStmt($this->buildPkeyCriteria(), $con); - $row = $stmt->fetch(PDO::FETCH_NUM); - $stmt->closeCursor(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aTaxRule = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param PropelPDO $con - * @return void - * @throws PropelException - * @throws Exception - * @see BaseObject::setDeleted() - * @see BaseObject::isDeleted() - */ - public function delete(PropelPDO $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $con->beginTransaction(); - try { - $deleteQuery = TaxRuleI18nQuery::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(TaxRuleI18nPeer::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); - TaxRuleI18nPeer::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param PropelPDO $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(PropelPDO $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTaxRule !== null) { - if ($this->aTaxRule->isModified() || $this->aTaxRule->isNew()) { - $affectedRows += $this->aTaxRule->save($con); - } - $this->setTaxRule($this->aTaxRule); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param PropelPDO $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(PropelPDO $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(TaxRuleI18nPeer::ID)) { - $modifiedColumns[':p' . $index++] = '`id`'; - } - if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) { - $modifiedColumns[':p' . $index++] = '`locale`'; - } - - $sql = sprintf( - 'INSERT INTO `tax_rule_i18n` (%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 '`locale`': - $stmt->bindValue($identifier, $this->locale, 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; - } - - $this->validationFailures = $res; - - return false; - } - - /** - * This function performs the validation work for complex object models. - * - * In addition to checking the current object, all related objects will - * also be validated. If all pass then true is returned; otherwise - * an aggreagated array of ValidationFailed objects will be returned. - * - * @param array $columns Array of column names to validate. - * @return mixed true if all validations pass; array of ValidationFailed objets otherwise. - */ - protected function doValidate($columns = null) - { - if (!$this->alreadyInValidation) { - $this->alreadyInValidation = true; - $retval = null; - - $failureMap = array(); - - - // We call the validate method on the following object(s) if they - // were passed to this object by their coresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aTaxRule !== null) { - if (!$this->aTaxRule->validate($columns)) { - $failureMap = array_merge($failureMap, $this->aTaxRule->getValidationFailures()); - } - } - - - if (($retval = TaxRuleI18nPeer::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 = TaxRuleI18nPeer::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->getLocale(); - 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['TaxRuleI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['TaxRuleI18n'][serialize($this->getPrimaryKey())] = true; - $keys = TaxRuleI18nPeer::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - ); - if ($includeForeignObjects) { - if (null !== $this->aTaxRule) { - $result['TaxRule'] = $this->aTaxRule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name peer name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. - * Defaults to BasePeer::TYPE_PHPNAME - * @return void - */ - public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) - { - $pos = TaxRuleI18nPeer::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->setLocale($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 = TaxRuleI18nPeer::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME); - - if ($this->isColumnModified(TaxRuleI18nPeer::ID)) $criteria->add(TaxRuleI18nPeer::ID, $this->id); - if ($this->isColumnModified(TaxRuleI18nPeer::LOCALE)) $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale); - - 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(TaxRuleI18nPeer::DATABASE_NAME); - $criteria->add(TaxRuleI18nPeer::ID, $this->id); - $criteria->add(TaxRuleI18nPeer::LOCALE, $this->locale); - - 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->getLocale(); - - 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->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * 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 TaxRuleI18n (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->setLocale($this->getLocale()); - - 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 TaxRuleI18n 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 TaxRuleI18nPeer - */ - public function getPeer() - { - if (self::$peer === null) { - self::$peer = new TaxRuleI18nPeer(); - } - - return self::$peer; - } - - /** - * Declares an association between this object and a TaxRule object. - * - * @param TaxRule $v - * @return TaxRuleI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setTaxRule(TaxRule $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aTaxRule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the TaxRule object, it will not be re-added. - if ($v !== null) { - $v->addTaxRuleI18n($this); - } - - - return $this; - } - - - /** - * Get the associated TaxRule object - * - * @param PropelPDO $con Optional Connection object. - * @param $doQuery Executes a query to get the object if required - * @return TaxRule The associated TaxRule object. - * @throws PropelException - */ - public function getTaxRule(PropelPDO $con = null, $doQuery = true) - { - if ($this->aTaxRule === null && ($this->id !== null) && $doQuery) { - $this->aTaxRule = TaxRuleQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aTaxRule->addTaxRuleI18ns($this); - */ - } - - return $this->aTaxRule; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->alreadyInSave = false; - $this->alreadyInValidation = false; - $this->alreadyInClearAllReferencesDeep = 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 && !$this->alreadyInClearAllReferencesDeep) { - $this->alreadyInClearAllReferencesDeep = true; - if ($this->aTaxRule instanceof Persistent) { - $this->aTaxRule->clearAllReferences($deep); - } - - $this->alreadyInClearAllReferencesDeep = false; - } // if ($deep) - - $this->aTaxRule = null; - } - - /** - * return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(TaxRuleI18nPeer::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/BaseTaxRuleI18nPeer.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php deleted file mode 100755 index fc1dfed70..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18nPeer.php +++ /dev/null @@ -1,996 +0,0 @@ - array ('Id', 'Locale', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'locale', ), - BasePeer::TYPE_COLNAME => array (TaxRuleI18nPeer::ID, TaxRuleI18nPeer::LOCALE, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'LOCALE', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'locale', ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. TaxRuleI18nPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Locale' => 1, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'locale' => 1, ), - BasePeer::TYPE_COLNAME => array (TaxRuleI18nPeer::ID => 0, TaxRuleI18nPeer::LOCALE => 1, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'LOCALE' => 1, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'locale' => 1, ), - BasePeer::TYPE_NUM => array (0, 1, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = TaxRuleI18nPeer::getFieldNames($toType); - $key = isset(TaxRuleI18nPeer::$fieldKeys[$fromType][$name]) ? TaxRuleI18nPeer::$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(TaxRuleI18nPeer::$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, TaxRuleI18nPeer::$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 TaxRuleI18nPeer::$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. TaxRuleI18nPeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(TaxRuleI18nPeer::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(TaxRuleI18nPeer::ID); - $criteria->addSelectColumn(TaxRuleI18nPeer::LOCALE); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.locale'); - } - } - - /** - * 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(TaxRuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::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 TaxRuleI18n - * @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 = TaxRuleI18nPeer::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 TaxRuleI18nPeer::populateObjects(TaxRuleI18nPeer::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 directly (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(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - TaxRuleI18nPeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::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 TaxRuleI18n $obj A TaxRuleI18n 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->getLocale())); - } // if key === null - TaxRuleI18nPeer::$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 TaxRuleI18n 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 TaxRuleI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - } 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 TaxRuleI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(TaxRuleI18nPeer::$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 TaxRuleI18n 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(TaxRuleI18nPeer::$instances[$key])) { - return TaxRuleI18nPeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (TaxRuleI18nPeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - TaxRuleI18nPeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to tax_rule_i18n - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null && $row[$startcol + 1] === null) { - return null; - } - - return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return array((int) $row[$startcol], (string) $row[$startcol + 1]); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = TaxRuleI18nPeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = TaxRuleI18nPeer::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; - TaxRuleI18nPeer::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 (TaxRuleI18n object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = TaxRuleI18nPeer::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 + TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = TaxRuleI18nPeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - TaxRuleI18nPeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - - /** - * Returns the number of rows matching criteria, joining the related TaxRule table - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return int Number of matching rows. - */ - public static function doCountJoinTaxRule(Criteria $criteria, $distinct = false, PropelPDO $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - // we're going to modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - - /** - * Selects a collection of TaxRuleI18n objects pre-filled with their TaxRule objects. - * @param Criteria $criteria - * @param PropelPDO $con - * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN - * @return array Array of TaxRuleI18n objects. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectJoinTaxRule(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) - { - $criteria = clone $criteria; - - // Set the correct dbName if it has not been overridden - if ($criteria->getDbName() == Propel::getDefaultDB()) { - $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME); - } - - TaxRuleI18nPeer::addSelectColumns($criteria); - $startcol = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS; - TaxRulePeer::addSelectColumns($criteria); - - $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - - $cls = TaxRuleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleI18nPeer::addInstanceToPool($obj1, $key1); - } // if $obj1 already loaded - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 already loaded - - // Add the $obj1 (TaxRuleI18n) to $obj2 (TaxRule) - $obj2->addTaxRuleI18n($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(TaxRuleI18nPeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRuleI18nPeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - - // Set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME); - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - - /** - * Selects a collection of TaxRuleI18n 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 TaxRuleI18n 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(TaxRuleI18nPeer::DATABASE_NAME); - } - - TaxRuleI18nPeer::addSelectColumns($criteria); - $startcol2 = TaxRuleI18nPeer::NUM_HYDRATE_COLUMNS; - - TaxRulePeer::addSelectColumns($criteria); - $startcol3 = $startcol2 + TaxRulePeer::NUM_HYDRATE_COLUMNS; - - $criteria->addJoin(TaxRuleI18nPeer::ID, TaxRulePeer::ID, $join_behavior); - - $stmt = BasePeer::doSelect($criteria, $con); - $results = array(); - - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key1 = TaxRuleI18nPeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj1 = TaxRuleI18nPeer::getInstanceFromPool($key1))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj1->hydrate($row, 0, true); // rehydrate - } else { - $cls = TaxRuleI18nPeer::getOMClass(); - - $obj1 = new $cls(); - $obj1->hydrate($row); - TaxRuleI18nPeer::addInstanceToPool($obj1, $key1); - } // if obj1 already loaded - - // Add objects for joined TaxRule rows - - $key2 = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol2); - if ($key2 !== null) { - $obj2 = TaxRulePeer::getInstanceFromPool($key2); - if (!$obj2) { - - $cls = TaxRulePeer::getOMClass(); - - $obj2 = new $cls(); - $obj2->hydrate($row, $startcol2); - TaxRulePeer::addInstanceToPool($obj2, $key2); - } // if obj2 loaded - - // Add the $obj1 (TaxRuleI18n) to the collection in $obj2 (TaxRule) - $obj2->addTaxRuleI18n($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(TaxRuleI18nPeer::DATABASE_NAME)->getTable(TaxRuleI18nPeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseTaxRuleI18nPeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseTaxRuleI18nPeer::TABLE_NAME)) { - $dbMap->addTableObject(new TaxRuleI18nTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return TaxRuleI18nPeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a TaxRuleI18n or Criteria object. - * - * @param mixed $values Criteria or TaxRuleI18n 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(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from TaxRuleI18n object - } - - - // Set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::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 TaxRuleI18n or Criteria object. - * - * @param mixed $values Criteria or TaxRuleI18n 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(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(TaxRuleI18nPeer::ID); - $value = $criteria->remove(TaxRuleI18nPeer::ID); - if ($value) { - $selectCriteria->add(TaxRuleI18nPeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME); - } - - $comparison = $criteria->getComparison(TaxRuleI18nPeer::LOCALE); - $value = $criteria->remove(TaxRuleI18nPeer::LOCALE); - if ($value) { - $selectCriteria->add(TaxRuleI18nPeer::LOCALE, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxRuleI18nPeer::TABLE_NAME); - } - - } else { // $values is TaxRuleI18n object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the tax_rule_i18n 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(TaxRuleI18nPeer::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(TaxRuleI18nPeer::TABLE_NAME, $con, TaxRuleI18nPeer::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). - TaxRuleI18nPeer::clearInstancePool(); - TaxRuleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a TaxRuleI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or TaxRuleI18n 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(TaxRuleI18nPeer::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. - TaxRuleI18nPeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof TaxRuleI18n) { // it's a model object - // invalidate the cache for this single object - TaxRuleI18nPeer::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(TaxRuleI18nPeer::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(TaxRuleI18nPeer::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(TaxRuleI18nPeer::LOCALE, $value[1])); - $criteria->addOr($criterion); - // we can invalidate the cache for this single PK - TaxRuleI18nPeer::removeInstanceFromPool($value); - } - } - - // Set the correct dbName - $criteria->setDbName(TaxRuleI18nPeer::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); - TaxRuleI18nPeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given TaxRuleI18n 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 TaxRuleI18n $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(TaxRuleI18nPeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(TaxRuleI18nPeer::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(TaxRuleI18nPeer::DATABASE_NAME, TaxRuleI18nPeer::TABLE_NAME, $columns); - } - - /** - * Retrieve object using using composite pkey values. - * @param int $id - * @param string $locale - * @param PropelPDO $con - * @return TaxRuleI18n - */ - public static function retrieveByPK($id, $locale, PropelPDO $con = null) { - $_instancePoolKey = serialize(array((string) $id, (string) $locale)); - if (null !== ($obj = TaxRuleI18nPeer::getInstanceFromPool($_instancePoolKey))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(TaxRuleI18nPeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $criteria = new Criteria(TaxRuleI18nPeer::DATABASE_NAME); - $criteria->add(TaxRuleI18nPeer::ID, $id); - $criteria->add(TaxRuleI18nPeer::LOCALE, $locale); - $v = TaxRuleI18nPeer::doSelect($criteria, $con); - - return !empty($v) ? $v[0] : null; - } -} // BaseTaxRuleI18nPeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseTaxRuleI18nPeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php deleted file mode 100755 index 9bf286bc6..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleI18nQuery.php +++ /dev/null @@ -1,405 +0,0 @@ -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, $locale] - * @param PropelPDO $con an optional connection object - * - * @return TaxRuleI18n|TaxRuleI18n[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = TaxRuleI18nPeer::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(TaxRuleI18nPeer::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 TaxRuleI18n A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `locale` FROM `tax_rule_i18n` WHERE `id` = :p0 AND `locale` = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $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 TaxRuleI18n(); - $obj->hydrate($row); - TaxRuleI18nPeer::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 TaxRuleI18n|TaxRuleI18n[]|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|TaxRuleI18n[]|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 TaxRuleI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(TaxRuleI18nPeer::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(TaxRuleI18nPeer::LOCALE, $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 TaxRuleI18nQuery 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(TaxRuleI18nPeer::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(TaxRuleI18nPeer::LOCALE, $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 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @see filterByTaxRule() - * - * @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 TaxRuleI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(TaxRuleI18nPeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRuleI18nPeer::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale 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 TaxRuleI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxRuleI18nPeer::LOCALE, $locale, $comparison); - } - - /** - * Filter the query by a related TaxRule object - * - * @param TaxRule|PropelObjectCollection $taxRule The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleI18nQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRule($taxRule, $comparison = null) - { - if ($taxRule instanceof TaxRule) { - return $this - ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->getId(), $comparison); - } elseif ($taxRule instanceof PropelObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(TaxRuleI18nPeer::ID, $taxRule->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByTaxRule() only accepts arguments of type TaxRule or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleI18nQuery The current query, for fluid interface - */ - public function joinTaxRule($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRule'); - } - - return $this; - } - - /** - * Use the TaxRule relation TaxRule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinTaxRule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRule', '\Thelia\Model\TaxRuleQuery'); - } - - /** - * Exclude object from result - * - * @param TaxRuleI18n $taxRuleI18n Object to remove from the list of results - * - * @return TaxRuleI18nQuery The current query, for fluid interface - */ - public function prune($taxRuleI18n = null) - { - if ($taxRuleI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(TaxRuleI18nPeer::ID), $taxRuleI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(TaxRuleI18nPeer::LOCALE), $taxRuleI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - -} diff --git a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php b/core/lib/Thelia/Model/om/BaseTaxRulePeer.php deleted file mode 100755 index bf825eb9f..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRulePeer.php +++ /dev/null @@ -1,814 +0,0 @@ - array ('Id', 'Code', 'Title', 'Description', 'CreatedAt', 'UpdatedAt', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'code', 'title', 'description', 'createdAt', 'updatedAt', ), - BasePeer::TYPE_COLNAME => array (TaxRulePeer::ID, TaxRulePeer::CODE, TaxRulePeer::TITLE, TaxRulePeer::DESCRIPTION, TaxRulePeer::CREATED_AT, TaxRulePeer::UPDATED_AT, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'TITLE', 'DESCRIPTION', 'CREATED_AT', 'UPDATED_AT', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'title', 'description', 'created_at', 'updated_at', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. TaxRulePeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Code' => 1, 'Title' => 2, 'Description' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - BasePeer::TYPE_COLNAME => array (TaxRulePeer::ID => 0, TaxRulePeer::CODE => 1, TaxRulePeer::TITLE => 2, TaxRulePeer::DESCRIPTION => 3, TaxRulePeer::CREATED_AT => 4, TaxRulePeer::UPDATED_AT => 5, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'title' => 2, 'description' => 3, 'created_at' => 4, 'updated_at' => 5, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, ) - ); - - /** - * Translates a fieldname to another type - * - * @param string $name field name - * @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @param string $toType One of the class type constants - * @return string translated name of the field. - * @throws PropelException - if the specified name could not be found in the fieldname mappings. - */ - public static function translateFieldName($name, $fromType, $toType) - { - $toNames = TaxRulePeer::getFieldNames($toType); - $key = isset(TaxRulePeer::$fieldKeys[$fromType][$name]) ? TaxRulePeer::$fieldKeys[$fromType][$name] : null; - if ($key === null) { - throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(TaxRulePeer::$fieldKeys[$fromType], true)); - } - - return $toNames[$key]; - } - - /** - * Returns an array of field names. - * - * @param string $type The type of fieldnames to return: - * One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME - * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM - * @return array A list of field names - * @throws PropelException - if the type is not valid. - */ - public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) - { - if (!array_key_exists($type, TaxRulePeer::$fieldNames)) { - throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); - } - - return TaxRulePeer::$fieldNames[$type]; - } - - /** - * Convenience method which changes table.column to alias.column. - * - * Using this method you can maintain SQL abstraction while using column aliases. - * - * $c->addAlias("alias1", TablePeer::TABLE_NAME); - * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); - * - * @param string $alias The alias for the current table. - * @param string $column The column name for current table. (i.e. TaxRulePeer::COLUMN_NAME). - * @return string - */ - public static function alias($alias, $column) - { - return str_replace(TaxRulePeer::TABLE_NAME.'.', $alias.'.', $column); - } - - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(TaxRulePeer::ID); - $criteria->addSelectColumn(TaxRulePeer::CODE); - $criteria->addSelectColumn(TaxRulePeer::TITLE); - $criteria->addSelectColumn(TaxRulePeer::DESCRIPTION); - $criteria->addSelectColumn(TaxRulePeer::CREATED_AT); - $criteria->addSelectColumn(TaxRulePeer::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.id'); - $criteria->addSelectColumn($alias . '.code'); - $criteria->addSelectColumn($alias . '.title'); - $criteria->addSelectColumn($alias . '.description'); - $criteria->addSelectColumn($alias . '.created_at'); - $criteria->addSelectColumn($alias . '.updated_at'); - } - } - - /** - * Returns the number of rows matching criteria. - * - * @param Criteria $criteria - * @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead. - * @param PropelPDO $con - * @return int Number of matching rows. - */ - public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null) - { - // we may modify criteria, so copy it first - $criteria = clone $criteria; - - // We need to set the primary table name, since in the case that there are no WHERE columns - // it will be impossible for the BasePeer::createSelectSql() method to determine which - // tables go into the FROM clause. - $criteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME); - - if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { - $criteria->setDistinct(); - } - - if (!$criteria->hasSelectClause()) { - TaxRulePeer::addSelectColumns($criteria); - } - - $criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count - $criteria->setDbName(TaxRulePeer::DATABASE_NAME); // Set the correct dbName - - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - // BasePeer returns a PDOStatement - $stmt = BasePeer::doCount($criteria, $con); - - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $count = (int) $row[0]; - } else { - $count = 0; // no rows returned; we infer that means 0 matches. - } - $stmt->closeCursor(); - - return $count; - } - /** - * Selects one object from the DB. - * - * @param Criteria $criteria object used to create the SELECT statement. - * @param PropelPDO $con - * @return TaxRule - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelectOne(Criteria $criteria, PropelPDO $con = null) - { - $critcopy = clone $criteria; - $critcopy->setLimit(1); - $objects = TaxRulePeer::doSelect($critcopy, $con); - if ($objects) { - return $objects[0]; - } - - return null; - } - /** - * Selects several row from the DB. - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con - * @return array Array of selected Objects - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doSelect(Criteria $criteria, PropelPDO $con = null) - { - return TaxRulePeer::populateObjects(TaxRulePeer::doSelectStmt($criteria, $con)); - } - /** - * Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement. - * - * Use this method directly if you want to work with an executed statement directly (for example - * to perform your own object hydration). - * - * @param Criteria $criteria The Criteria object used to build the SELECT statement. - * @param PropelPDO $con The connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return PDOStatement The executed PDOStatement object. - * @see BasePeer::doSelect() - */ - public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - if (!$criteria->hasSelectClause()) { - $criteria = clone $criteria; - TaxRulePeer::addSelectColumns($criteria); - } - - // Set the correct dbName - $criteria->setDbName(TaxRulePeer::DATABASE_NAME); - - // BasePeer returns a PDOStatement - return BasePeer::doSelect($criteria, $con); - } - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doSelect*() - * methods in your stub classes -- you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by doSelect*() - * and retrieveByPK*() calls. - * - * @param TaxRule $obj A TaxRule object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if ($key === null) { - $key = (string) $obj->getId(); - } // if key === null - TaxRulePeer::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A TaxRule object or a primary key value. - * - * @return void - * @throws PropelException - if the value is invalid. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && $value !== null) { - if (is_object($value) && $value instanceof TaxRule) { - $key = (string) $value->getId(); - } elseif (is_scalar($value)) { - // assume we've been passed a primary key - $key = (string) $value; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or TaxRule object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); - throw $e; - } - - unset(TaxRulePeer::$instances[$key]); - } - } // removeInstanceFromPool() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param string $key The key (@see getPrimaryKeyHash()) for this instance. - * @return TaxRule Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. - * @see getPrimaryKeyHash() - */ - public static function getInstanceFromPool($key) - { - if (Propel::isInstancePoolingEnabled()) { - if (isset(TaxRulePeer::$instances[$key])) { - return TaxRulePeer::$instances[$key]; - } - } - - return null; // just to be explicit - } - - /** - * Clear the instance pool. - * - * @return void - */ - public static function clearInstancePool($and_clear_all_references = false) - { - if ($and_clear_all_references) - { - foreach (TaxRulePeer::$instances as $instance) - { - $instance->clearAllReferences(true); - } - } - TaxRulePeer::$instances = array(); - } - - /** - * Method to invalidate the instance pool of all tables related to tax_rule - * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ProductPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - ProductPeer::clearInstancePool(); - // Invalidate objects in TaxRuleCountryPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxRuleCountryPeer::clearInstancePool(); - // Invalidate objects in TaxRuleI18nPeer instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - TaxRuleI18nPeer::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return string A string version of PK or null if the components of primary key in result array are all null. - */ - public static function getPrimaryKeyHashFromRow($row, $startcol = 0) - { - // If the PK cannot be derived from the row, return null. - if ($row[$startcol] === null) { - return null; - } - - return (string) $row[$startcol]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $startcol = 0) - { - - return (int) $row[$startcol]; - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(PDOStatement $stmt) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = TaxRulePeer::getOMClass(); - // populate the object(s) - while ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $key = TaxRulePeer::getPrimaryKeyHashFromRow($row, 0); - if (null !== ($obj = TaxRulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - TaxRulePeer::addInstanceToPool($obj, $key); - } // if key exists - } - $stmt->closeCursor(); - - return $results; - } - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row PropelPDO resultset row. - * @param int $startcol The 0-based offset for reading from the resultset row. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (TaxRule object, last column rank) - */ - public static function populateObject($row, $startcol = 0) - { - $key = TaxRulePeer::getPrimaryKeyHashFromRow($row, $startcol); - if (null !== ($obj = TaxRulePeer::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $startcol, true); // rehydrate - $col = $startcol + TaxRulePeer::NUM_HYDRATE_COLUMNS; - } else { - $cls = TaxRulePeer::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $startcol); - TaxRulePeer::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * Returns the TableMap related to this peer. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getDatabaseMap(TaxRulePeer::DATABASE_NAME)->getTable(TaxRulePeer::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this peer class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getDatabaseMap(BaseTaxRulePeer::DATABASE_NAME); - if (!$dbMap->hasTable(BaseTaxRulePeer::TABLE_NAME)) { - $dbMap->addTableObject(new TaxRuleTableMap()); - } - } - - /** - * The class that the Peer will make instances of. - * - * - * @return string ClassName - */ - public static function getOMClass($row = 0, $colnum = 0) - { - return TaxRulePeer::OM_CLASS; - } - - /** - * Performs an INSERT on the database, given a TaxRule or Criteria object. - * - * @param mixed $values Criteria or TaxRule object containing data that is used to create the INSERT statement. - * @param PropelPDO $con the PropelPDO connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - } else { - $criteria = $values->buildCriteria(); // build Criteria from TaxRule object - } - - if ($criteria->containsKey(TaxRulePeer::ID) && $criteria->keyContainsValue(TaxRulePeer::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.TaxRulePeer::ID.')'); - } - - - // Set the correct dbName - $criteria->setDbName(TaxRulePeer::DATABASE_NAME); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = BasePeer::doInsert($criteria, $con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - - /** - * Performs an UPDATE on the database, given a TaxRule or Criteria object. - * - * @param mixed $values Criteria or TaxRule object containing data that is used to create the UPDATE statement. - * @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doUpdate($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - $selectCriteria = new Criteria(TaxRulePeer::DATABASE_NAME); - - if ($values instanceof Criteria) { - $criteria = clone $values; // rename for clarity - - $comparison = $criteria->getComparison(TaxRulePeer::ID); - $value = $criteria->remove(TaxRulePeer::ID); - if ($value) { - $selectCriteria->add(TaxRulePeer::ID, $value, $comparison); - } else { - $selectCriteria->setPrimaryTableName(TaxRulePeer::TABLE_NAME); - } - - } else { // $values is TaxRule object - $criteria = $values->buildCriteria(); // gets full criteria - $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) - } - - // set the correct dbName - $criteria->setDbName(TaxRulePeer::DATABASE_NAME); - - return BasePeer::doUpdate($selectCriteria, $criteria, $con); - } - - /** - * Deletes all rows from the tax_rule table. - * - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - * @throws PropelException - */ - public static function doDeleteAll(PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += BasePeer::doDeleteAll(TaxRulePeer::TABLE_NAME, $con, TaxRulePeer::DATABASE_NAME); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - TaxRulePeer::clearInstancePool(); - TaxRulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs a DELETE on the database, given a TaxRule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or TaxRule object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param PropelPDO $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); - } - - if ($values instanceof Criteria) { - // invalidate the cache for all objects of this type, since we have no - // way of knowing (without running a query) what objects should be invalidated - // from the cache based on this Criteria. - TaxRulePeer::clearInstancePool(); - // rename for clarity - $criteria = clone $values; - } elseif ($values instanceof TaxRule) { // it's a model object - // invalidate the cache for this single object - TaxRulePeer::removeInstanceFromPool($values); - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - $criteria->add(TaxRulePeer::ID, (array) $values, Criteria::IN); - // invalidate the cache for this object(s) - foreach ((array) $values as $singleval) { - TaxRulePeer::removeInstanceFromPool($singleval); - } - } - - // Set the correct dbName - $criteria->setDbName(TaxRulePeer::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - $affectedRows += BasePeer::doDelete($criteria, $con); - TaxRulePeer::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Validates all modified columns of given TaxRule object. - * If parameter $columns is either a single column name or an array of column names - * than only those columns are validated. - * - * NOTICE: This does not apply to primary or foreign keys for now. - * - * @param TaxRule $obj The object to validate. - * @param mixed $cols Column name or array of column names. - * - * @return mixed TRUE if all columns are valid or the error message of the first invalid column. - */ - public static function doValidate($obj, $cols = null) - { - $columns = array(); - - if ($cols) { - $dbMap = Propel::getDatabaseMap(TaxRulePeer::DATABASE_NAME); - $tableMap = $dbMap->getTable(TaxRulePeer::TABLE_NAME); - - if (! is_array($cols)) { - $cols = array($cols); - } - - foreach ($cols as $colName) { - if ($tableMap->hasColumn($colName)) { - $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); - $columns[$colName] = $obj->$get(); - } - } - } else { - - } - - return BasePeer::doValidate(TaxRulePeer::DATABASE_NAME, TaxRulePeer::TABLE_NAME, $columns); - } - - /** - * Retrieve a single object by pkey. - * - * @param int $pk the primary key. - * @param PropelPDO $con the connection to use - * @return TaxRule - */ - public static function retrieveByPK($pk, PropelPDO $con = null) - { - - if (null !== ($obj = TaxRulePeer::getInstanceFromPool((string) $pk))) { - return $obj; - } - - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - $criteria->add(TaxRulePeer::ID, $pk); - - $v = TaxRulePeer::doSelect($criteria, $con); - - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param PropelPDO $con the connection to use - * @return TaxRule[] - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, PropelPDO $con = null) - { - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(TaxRulePeer::DATABASE_NAME); - $criteria->add(TaxRulePeer::ID, $pks, Criteria::IN); - $objs = TaxRulePeer::doSelect($criteria, $con); - } - - return $objs; - } - -} // BaseTaxRulePeer - -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -BaseTaxRulePeer::buildTableMap(); - diff --git a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php b/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php deleted file mode 100755 index 5829651c3..000000000 --- a/core/lib/Thelia/Model/om/BaseTaxRuleQuery.php +++ /dev/null @@ -1,839 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con an optional connection object - * - * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = TaxRulePeer::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is alredy in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getConnection(TaxRulePeer::DATABASE_NAME, Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Alias of findPk to use instance pooling - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRule A model object, or null if the key is not found - * @throws PropelException - */ - public function findOneById($key, $con = null) - { - return $this->findPk($key, $con); - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRule A model object, or null if the key is not found - * @throws PropelException - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT `id`, `code`, `title`, `description`, `created_at`, `updated_at` FROM `tax_rule` WHERE `id` = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); - } - $obj = null; - if ($row = $stmt->fetch(PDO::FETCH_NUM)) { - $obj = new TaxRule(); - $obj->hydrate($row); - TaxRulePeer::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param PropelPDO $con A connection object - * - * @return TaxRule|TaxRule[]|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($stmt); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param PropelPDO $con an optional connection object - * - * @return PropelObjectCollection|TaxRule[]|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if ($con === null) { - $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $stmt = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($stmt); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(TaxRulePeer::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(TaxRulePeer::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id >= 12 - * $query->filterById(array('max' => 12)); // WHERE id <= 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(TaxRulePeer::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(TaxRulePeer::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRulePeer::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxRulePeer::CODE, $code, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxRulePeer::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(TaxRulePeer::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRulePeer::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related Product object - * - * @param Product|PropelObjectCollection $product the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByProduct($product, $comparison = null) - { - if ($product instanceof Product) { - return $this - ->addUsingAlias(TaxRulePeer::ID, $product->getTaxRuleId(), $comparison); - } elseif ($product instanceof PropelObjectCollection) { - return $this - ->useProductQuery() - ->filterByPrimaryKeys($product->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the Product relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinProduct($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Product'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Product'); - } - - return $this; - } - - /** - * Use the Product relation Product object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ProductQuery A secondary query class using the current class as primary query - */ - public function useProductQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinProduct($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Product', '\Thelia\Model\ProductQuery'); - } - - /** - * Filter the query by a related TaxRuleCountry object - * - * @param TaxRuleCountry|PropelObjectCollection $taxRuleCountry the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRuleCountry($taxRuleCountry, $comparison = null) - { - if ($taxRuleCountry instanceof TaxRuleCountry) { - return $this - ->addUsingAlias(TaxRulePeer::ID, $taxRuleCountry->getTaxRuleId(), $comparison); - } elseif ($taxRuleCountry instanceof PropelObjectCollection) { - return $this - ->useTaxRuleCountryQuery() - ->filterByPrimaryKeys($taxRuleCountry->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxRuleCountry() only accepts arguments of type TaxRuleCountry or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRuleCountry relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinTaxRuleCountry($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRuleCountry'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRuleCountry'); - } - - return $this; - } - - /** - * Use the TaxRuleCountry relation TaxRuleCountry object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleCountryQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleCountryQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinTaxRuleCountry($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleCountry', '\Thelia\Model\TaxRuleCountryQuery'); - } - - /** - * Filter the query by a related TaxRuleI18n object - * - * @param TaxRuleI18n|PropelObjectCollection $taxRuleI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return TaxRuleQuery The current query, for fluid interface - * @throws PropelException - if the provided filter is invalid. - */ - public function filterByTaxRuleI18n($taxRuleI18n, $comparison = null) - { - if ($taxRuleI18n instanceof TaxRuleI18n) { - return $this - ->addUsingAlias(TaxRulePeer::ID, $taxRuleI18n->getId(), $comparison); - } elseif ($taxRuleI18n instanceof PropelObjectCollection) { - return $this - ->useTaxRuleI18nQuery() - ->filterByPrimaryKeys($taxRuleI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByTaxRuleI18n() only accepts arguments of type TaxRuleI18n or PropelCollection'); - } - } - - /** - * Adds a JOIN clause to the query using the TaxRuleI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinTaxRuleI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('TaxRuleI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'TaxRuleI18n'); - } - - return $this; - } - - /** - * Use the TaxRuleI18n relation TaxRuleI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\TaxRuleI18nQuery A secondary query class using the current class as primary query - */ - public function useTaxRuleI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinTaxRuleI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', '\Thelia\Model\TaxRuleI18nQuery'); - } - - /** - * Exclude object from result - * - * @param TaxRule $taxRule Object to remove from the list of results - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function prune($taxRule = null) - { - if ($taxRule) { - $this->addUsingAlias(TaxRulePeer::ID, $taxRule->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(TaxRulePeer::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(TaxRulePeer::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(TaxRulePeer::UPDATED_AT); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(TaxRulePeer::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by create date desc - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(TaxRulePeer::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(TaxRulePeer::CREATED_AT); - } - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; - - return $this - ->joinTaxRuleI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxRuleQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('TaxRuleI18n'); - $this->with['TaxRuleI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return TaxRuleI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'TaxRuleI18n', 'Thelia\Model\TaxRuleI18nQuery'); - } - -} diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index d7c2b2e62..b6d0f8c10 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -13,22 +13,9 @@ An image from asset directory : jQuery data:
-
-

Category loop example

-
    - {loop type="category" name="catloop1"} -
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}, children: {$NB_CHILD} - {ifloop rel="inner1"} -
      - {loop type="category" name="inner1" parent="{$ID}"} -
    • Sub cat {$ID} (parent is {$PARENT}): {$TITLE}
    • - {/loop} -
    - {/ifloop} -
  • - {/loop} -
-
+{loop type="category" name="catloop1" } +
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • +{/loop}

    Conditional example #1

    @@ -66,9 +53,7 @@ An image from asset directory : {elseloop rel="catloop2"}

    ... but catloop2 is still empty :-)

    {/elseloop} - {ifloop rel="catloop1"} -

    ... and catloop1 is still NOT empty :-)

    - {/ifloop} +
    @@ -78,12 +63,7 @@ An image from asset directory : {/for}
    -
    -

    Loops also work with #

    - {loop type="category" name="catloop1"} - #TITLE : {#DESCRIPTION|upper} #NOTATAG
    - {/loop} -
    +

    Some pagination

    From 5fbb923e401c4a28ee0220fc3d85f12927da973a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 5 Jul 2013 09:43:49 +0200 Subject: [PATCH 32/35] end propel 2 migration --- .../Thelia/Core/Template/Loop/Category.php | 1 - core/lib/Thelia/Model/Customer.php | 1 + templates/smarty-sample/index.html | 21 ++++++++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Category.php b/core/lib/Thelia/Core/Template/Loop/Category.php index 9f1357444..7240b688c 100755 --- a/core/lib/Thelia/Core/Template/Loop/Category.php +++ b/core/lib/Thelia/Core/Template/Loop/Category.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; -use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; diff --git a/core/lib/Thelia/Model/Customer.php b/core/lib/Thelia/Model/Customer.php index e6cf6f18c..812a134ea 100644 --- a/core/lib/Thelia/Model/Customer.php +++ b/core/lib/Thelia/Model/Customer.php @@ -28,6 +28,7 @@ class Customer extends BaseCustomer { * @param int $countryId customer country id (from Country table) * @param string $email customer email, must be unique * @param string $plainPassword customer plain password, hash is made calling setPassword method. Not mandatory parameter but an exception is thrown if customer is new without password + * @param string $lang * @param int $reseller * @param null $sponsor * @param int $discount diff --git a/templates/smarty-sample/index.html b/templates/smarty-sample/index.html index 8ca3909fc..5a73519b0 100755 --- a/templates/smarty-sample/index.html +++ b/templates/smarty-sample/index.html @@ -13,9 +13,24 @@ An image from asset directory : jQuery data:
    -{loop type="category" name="catloop1" } -
  • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}
  • -{/loop} +
    +

    Category loop example

    +
      + {loop type="category" name="catloop1"} +
    • {$__COUNT__}/{$__TOTAL__} : {$ID} {$TITLE}, children: {$NB_CHILD} + {ifloop rel="inner1"} +
        + {loop type="category" name="inner1" parent="{$ID}"} +
      • Sub cat {$ID} (parent is {$PARENT}): {$TITLE}
      • + {/loop} +
      + {/ifloop} +
    • + {/loop} +
    +
    + +
    From 9ed14bf7a30bae11752f8cd5daade84086437274 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 5 Jul 2013 11:21:31 +0200 Subject: [PATCH 33/35] change default locale to en_US --- core/lib/Thelia/Model/Base/Attribute.php | 10 +++++----- core/lib/Thelia/Model/Base/AttributeAv.php | 10 +++++----- core/lib/Thelia/Model/Base/AttributeAvI18n.php | 6 +++--- core/lib/Thelia/Model/Base/AttributeAvQuery.php | 6 +++--- core/lib/Thelia/Model/Base/AttributeI18n.php | 6 +++--- core/lib/Thelia/Model/Base/AttributeQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Category.php | 10 +++++----- core/lib/Thelia/Model/Base/CategoryI18n.php | 6 +++--- core/lib/Thelia/Model/Base/CategoryQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Config.php | 10 +++++----- core/lib/Thelia/Model/Base/ConfigI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ConfigQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Content.php | 10 +++++----- core/lib/Thelia/Model/Base/ContentI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ContentQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Country.php | 10 +++++----- core/lib/Thelia/Model/Base/CountryI18n.php | 6 +++--- core/lib/Thelia/Model/Base/CountryQuery.php | 6 +++--- core/lib/Thelia/Model/Base/CustomerTitle.php | 10 +++++----- core/lib/Thelia/Model/Base/CustomerTitleI18n.php | 6 +++--- core/lib/Thelia/Model/Base/CustomerTitleQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Document.php | 10 +++++----- core/lib/Thelia/Model/Base/DocumentI18n.php | 6 +++--- core/lib/Thelia/Model/Base/DocumentQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Feature.php | 10 +++++----- core/lib/Thelia/Model/Base/FeatureAv.php | 10 +++++----- core/lib/Thelia/Model/Base/FeatureAvI18n.php | 6 +++--- core/lib/Thelia/Model/Base/FeatureAvQuery.php | 6 +++--- core/lib/Thelia/Model/Base/FeatureI18n.php | 6 +++--- core/lib/Thelia/Model/Base/FeatureQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Folder.php | 10 +++++----- core/lib/Thelia/Model/Base/FolderI18n.php | 6 +++--- core/lib/Thelia/Model/Base/FolderQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Group.php | 10 +++++----- core/lib/Thelia/Model/Base/GroupI18n.php | 6 +++--- core/lib/Thelia/Model/Base/GroupQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Image.php | 10 +++++----- core/lib/Thelia/Model/Base/ImageI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ImageQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Message.php | 10 +++++----- core/lib/Thelia/Model/Base/MessageI18n.php | 6 +++--- core/lib/Thelia/Model/Base/MessageQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Module.php | 10 +++++----- core/lib/Thelia/Model/Base/ModuleI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ModuleQuery.php | 6 +++--- core/lib/Thelia/Model/Base/OrderStatus.php | 10 +++++----- core/lib/Thelia/Model/Base/OrderStatusI18n.php | 6 +++--- core/lib/Thelia/Model/Base/OrderStatusQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Product.php | 10 +++++----- core/lib/Thelia/Model/Base/ProductI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ProductQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Resource.php | 10 +++++----- core/lib/Thelia/Model/Base/ResourceI18n.php | 6 +++--- core/lib/Thelia/Model/Base/ResourceQuery.php | 6 +++--- core/lib/Thelia/Model/Base/Tax.php | 10 +++++----- core/lib/Thelia/Model/Base/TaxI18n.php | 6 +++--- core/lib/Thelia/Model/Base/TaxQuery.php | 6 +++--- core/lib/Thelia/Model/Base/TaxRule.php | 10 +++++----- core/lib/Thelia/Model/Base/TaxRuleI18n.php | 6 +++--- core/lib/Thelia/Model/Base/TaxRuleQuery.php | 6 +++--- core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/AttributeAvTableMap.php | 2 +- core/lib/Thelia/Model/Map/AttributeI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/AttributeTableMap.php | 2 +- core/lib/Thelia/Model/Map/CategoryI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CategoryTableMap.php | 2 +- core/lib/Thelia/Model/Map/ConfigI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ConfigTableMap.php | 2 +- core/lib/Thelia/Model/Map/ContentI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ContentTableMap.php | 2 +- core/lib/Thelia/Model/Map/CountryI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CountryTableMap.php | 2 +- .../lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/CustomerTitleTableMap.php | 2 +- core/lib/Thelia/Model/Map/DocumentI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/DocumentTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureAvTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FeatureTableMap.php | 2 +- core/lib/Thelia/Model/Map/FolderI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/FolderTableMap.php | 2 +- core/lib/Thelia/Model/Map/GroupI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/GroupTableMap.php | 2 +- core/lib/Thelia/Model/Map/ImageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ImageTableMap.php | 2 +- core/lib/Thelia/Model/Map/MessageI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/MessageTableMap.php | 2 +- core/lib/Thelia/Model/Map/ModuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ModuleTableMap.php | 2 +- core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/OrderStatusTableMap.php | 2 +- core/lib/Thelia/Model/Map/ProductI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ProductTableMap.php | 2 +- core/lib/Thelia/Model/Map/ResourceI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/ResourceTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxRuleTableMap.php | 2 +- core/lib/Thelia/Model/Map/TaxTableMap.php | 2 +- 100 files changed, 260 insertions(+), 260 deletions(-) diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index 481398b95..9995df65f 100644 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -132,7 +132,7 @@ abstract class Attribute implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2554,7 +2554,7 @@ abstract class Attribute implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAttributeAvs instanceof Collection) { @@ -2612,7 +2612,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2636,7 +2636,7 @@ abstract class Attribute implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeI18ns) { @@ -2671,7 +2671,7 @@ abstract class Attribute implements ActiveRecordInterface * * @return ChildAttribute The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAv.php b/core/lib/Thelia/Model/Base/AttributeAv.php index baed904dd..be785f3e6 100644 --- a/core/lib/Thelia/Model/Base/AttributeAv.php +++ b/core/lib/Thelia/Model/Base/AttributeAv.php @@ -122,7 +122,7 @@ abstract class AttributeAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1903,7 +1903,7 @@ abstract class AttributeAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAttributeCombinations instanceof Collection) { @@ -1950,7 +1950,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1974,7 +1974,7 @@ abstract class AttributeAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildAttributeAvI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collAttributeAvI18ns) { @@ -2009,7 +2009,7 @@ abstract class AttributeAv implements ActiveRecordInterface * * @return ChildAttributeAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildAttributeAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/AttributeAvI18n.php b/core/lib/Thelia/Model/Base/AttributeAvI18n.php index bcd1c7453..3e7b9afcd 100644 --- a/core/lib/Thelia/Model/Base/AttributeAvI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeAvI18n.php @@ -61,7 +61,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class AttributeAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeAvQuery.php b/core/lib/Thelia/Model/Base/AttributeAvQuery.php index 4f724b4f4..8ebfaa8c9 100644 --- a/core/lib/Thelia/Model/Base/AttributeAvQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeAvQuery.php @@ -841,7 +841,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeAvI18n'; @@ -859,7 +859,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -880,7 +880,7 @@ abstract class AttributeAvQuery extends ModelCriteria * * @return ChildAttributeAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/AttributeI18n.php b/core/lib/Thelia/Model/Base/AttributeI18n.php index b8865769c..0e4a1db8f 100644 --- a/core/lib/Thelia/Model/Base/AttributeI18n.php +++ b/core/lib/Thelia/Model/Base/AttributeI18n.php @@ -61,7 +61,7 @@ abstract class AttributeI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class AttributeI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php index cbb690efb..cabbaf7ac 100644 --- a/core/lib/Thelia/Model/Base/AttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -886,7 +886,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'AttributeI18n'; @@ -904,7 +904,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -925,7 +925,7 @@ abstract class AttributeQuery extends ModelCriteria * * @return ChildAttributeI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Category.php b/core/lib/Thelia/Model/Base/Category.php index a5df03229..1a9e0b56a 100644 --- a/core/lib/Thelia/Model/Base/Category.php +++ b/core/lib/Thelia/Model/Base/Category.php @@ -224,7 +224,7 @@ abstract class Category implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -5030,7 +5030,7 @@ abstract class Category implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -5116,7 +5116,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -5140,7 +5140,7 @@ abstract class Category implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCategoryI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCategoryI18ns) { @@ -5175,7 +5175,7 @@ abstract class Category implements ActiveRecordInterface * * @return ChildCategory The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCategoryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CategoryI18n.php b/core/lib/Thelia/Model/Base/CategoryI18n.php index 65fa17063..83d62572d 100644 --- a/core/lib/Thelia/Model/Base/CategoryI18n.php +++ b/core/lib/Thelia/Model/Base/CategoryI18n.php @@ -61,7 +61,7 @@ abstract class CategoryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class CategoryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/CategoryQuery.php b/core/lib/Thelia/Model/Base/CategoryQuery.php index caf05cbec..c7bcc32e1 100644 --- a/core/lib/Thelia/Model/Base/CategoryQuery.php +++ b/core/lib/Thelia/Model/Base/CategoryQuery.php @@ -1560,7 +1560,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CategoryI18n'; @@ -1578,7 +1578,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1599,7 +1599,7 @@ abstract class CategoryQuery extends ModelCriteria * * @return ChildCategoryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Config.php b/core/lib/Thelia/Model/Base/Config.php index 140cdb82d..d687ffefe 100644 --- a/core/lib/Thelia/Model/Base/Config.php +++ b/core/lib/Thelia/Model/Base/Config.php @@ -121,7 +121,7 @@ abstract class Config implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1642,7 +1642,7 @@ abstract class Config implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collConfigI18ns instanceof Collection) { @@ -1684,7 +1684,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1708,7 +1708,7 @@ abstract class Config implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildConfigI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collConfigI18ns) { @@ -1743,7 +1743,7 @@ abstract class Config implements ActiveRecordInterface * * @return ChildConfig The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildConfigI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ConfigI18n.php b/core/lib/Thelia/Model/Base/ConfigI18n.php index e73e27514..6247e15d1 100644 --- a/core/lib/Thelia/Model/Base/ConfigI18n.php +++ b/core/lib/Thelia/Model/Base/ConfigI18n.php @@ -61,7 +61,7 @@ abstract class ConfigI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ConfigI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ConfigQuery.php b/core/lib/Thelia/Model/Base/ConfigQuery.php index b2ddc3409..ef47308a4 100644 --- a/core/lib/Thelia/Model/Base/ConfigQuery.php +++ b/core/lib/Thelia/Model/Base/ConfigQuery.php @@ -749,7 +749,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ConfigI18n'; @@ -767,7 +767,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -788,7 +788,7 @@ abstract class ConfigQuery extends ModelCriteria * * @return ChildConfigI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Content.php b/core/lib/Thelia/Model/Base/Content.php index eec31f072..abe90ea5c 100644 --- a/core/lib/Thelia/Model/Base/Content.php +++ b/core/lib/Thelia/Model/Base/Content.php @@ -182,7 +182,7 @@ abstract class Content implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -3870,7 +3870,7 @@ abstract class Content implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collContentAssocs instanceof Collection) { @@ -3940,7 +3940,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -3964,7 +3964,7 @@ abstract class Content implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildContentI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collContentI18ns) { @@ -3999,7 +3999,7 @@ abstract class Content implements ActiveRecordInterface * * @return ChildContent The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildContentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ContentI18n.php b/core/lib/Thelia/Model/Base/ContentI18n.php index 14ff02b39..d3974522b 100644 --- a/core/lib/Thelia/Model/Base/ContentI18n.php +++ b/core/lib/Thelia/Model/Base/ContentI18n.php @@ -61,7 +61,7 @@ abstract class ContentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ContentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ContentQuery.php b/core/lib/Thelia/Model/Base/ContentQuery.php index 2c4b9da04..aec6e3678 100644 --- a/core/lib/Thelia/Model/Base/ContentQuery.php +++ b/core/lib/Thelia/Model/Base/ContentQuery.php @@ -1294,7 +1294,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ContentI18n'; @@ -1312,7 +1312,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1333,7 +1333,7 @@ abstract class ContentQuery extends ModelCriteria * * @return ChildContentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Country.php b/core/lib/Thelia/Model/Base/Country.php index c59c3585e..4d21c09c2 100644 --- a/core/lib/Thelia/Model/Base/Country.php +++ b/core/lib/Thelia/Model/Base/Country.php @@ -134,7 +134,7 @@ abstract class Country implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2005,7 +2005,7 @@ abstract class Country implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -2052,7 +2052,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2076,7 +2076,7 @@ abstract class Country implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCountryI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCountryI18ns) { @@ -2111,7 +2111,7 @@ abstract class Country implements ActiveRecordInterface * * @return ChildCountry The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCountryI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CountryI18n.php b/core/lib/Thelia/Model/Base/CountryI18n.php index 270a9d3f7..be63955ca 100644 --- a/core/lib/Thelia/Model/Base/CountryI18n.php +++ b/core/lib/Thelia/Model/Base/CountryI18n.php @@ -61,7 +61,7 @@ abstract class CountryI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class CountryI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/CountryQuery.php b/core/lib/Thelia/Model/Base/CountryQuery.php index 1b5c02209..04a66530c 100644 --- a/core/lib/Thelia/Model/Base/CountryQuery.php +++ b/core/lib/Thelia/Model/Base/CountryQuery.php @@ -895,7 +895,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CountryI18n'; @@ -913,7 +913,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -934,7 +934,7 @@ abstract class CountryQuery extends ModelCriteria * * @return ChildCountryI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/CustomerTitle.php b/core/lib/Thelia/Model/Base/CustomerTitle.php index c060f7fae..d126839d0 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitle.php +++ b/core/lib/Thelia/Model/Base/CustomerTitle.php @@ -124,7 +124,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2083,7 +2083,7 @@ abstract class CustomerTitle implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collCustomers instanceof Collection) { @@ -2133,7 +2133,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2157,7 +2157,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildCustomerTitleI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collCustomerTitleI18ns) { @@ -2192,7 +2192,7 @@ abstract class CustomerTitle implements ActiveRecordInterface * * @return ChildCustomerTitle The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildCustomerTitleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php index 38e47ecda..c68b87123 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitleI18n.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleI18n.php @@ -61,7 +61,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -500,7 +500,7 @@ abstract class CustomerTitleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php index a0b6d7b05..940db1425 100644 --- a/core/lib/Thelia/Model/Base/CustomerTitleQuery.php +++ b/core/lib/Thelia/Model/Base/CustomerTitleQuery.php @@ -825,7 +825,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'CustomerTitleI18n'; @@ -843,7 +843,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -864,7 +864,7 @@ abstract class CustomerTitleQuery extends ModelCriteria * * @return ChildCustomerTitleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Document.php b/core/lib/Thelia/Model/Base/Document.php index b12293f33..10ee4e818 100644 --- a/core/lib/Thelia/Model/Base/Document.php +++ b/core/lib/Thelia/Model/Base/Document.php @@ -159,7 +159,7 @@ abstract class Document implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2042,7 +2042,7 @@ abstract class Document implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collDocumentI18ns instanceof Collection) { @@ -2088,7 +2088,7 @@ abstract class Document implements ActiveRecordInterface * * @return ChildDocument The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2112,7 +2112,7 @@ abstract class Document implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildDocumentI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collDocumentI18ns) { @@ -2147,7 +2147,7 @@ abstract class Document implements ActiveRecordInterface * * @return ChildDocument The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildDocumentI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/DocumentI18n.php b/core/lib/Thelia/Model/Base/DocumentI18n.php index adc6acd36..9c3b7376e 100644 --- a/core/lib/Thelia/Model/Base/DocumentI18n.php +++ b/core/lib/Thelia/Model/Base/DocumentI18n.php @@ -61,7 +61,7 @@ abstract class DocumentI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class DocumentI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/DocumentQuery.php b/core/lib/Thelia/Model/Base/DocumentQuery.php index 20c897994..94a9e0670 100644 --- a/core/lib/Thelia/Model/Base/DocumentQuery.php +++ b/core/lib/Thelia/Model/Base/DocumentQuery.php @@ -1175,7 +1175,7 @@ abstract class DocumentQuery extends ModelCriteria * * @return ChildDocumentQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'DocumentI18n'; @@ -1193,7 +1193,7 @@ abstract class DocumentQuery extends ModelCriteria * * @return ChildDocumentQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1214,7 +1214,7 @@ abstract class DocumentQuery extends ModelCriteria * * @return ChildDocumentI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index 33125c87b..c8e5e2603 100644 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -139,7 +139,7 @@ abstract class Feature implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2628,7 +2628,7 @@ abstract class Feature implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collFeatureAvs instanceof Collection) { @@ -2686,7 +2686,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2710,7 +2710,7 @@ abstract class Feature implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureI18ns) { @@ -2745,7 +2745,7 @@ abstract class Feature implements ActiveRecordInterface * * @return ChildFeature The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAv.php b/core/lib/Thelia/Model/Base/FeatureAv.php index baa930702..f60ee9eb2 100644 --- a/core/lib/Thelia/Model/Base/FeatureAv.php +++ b/core/lib/Thelia/Model/Base/FeatureAv.php @@ -116,7 +116,7 @@ abstract class FeatureAv implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1842,7 +1842,7 @@ abstract class FeatureAv implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collFeatureProds instanceof Collection) { @@ -1889,7 +1889,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1913,7 +1913,7 @@ abstract class FeatureAv implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFeatureAvI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFeatureAvI18ns) { @@ -1948,7 +1948,7 @@ abstract class FeatureAv implements ActiveRecordInterface * * @return ChildFeatureAv The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFeatureAvI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FeatureAvI18n.php b/core/lib/Thelia/Model/Base/FeatureAvI18n.php index aa524c430..7cbca8129 100644 --- a/core/lib/Thelia/Model/Base/FeatureAvI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureAvI18n.php @@ -61,7 +61,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class FeatureAvI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureAvQuery.php b/core/lib/Thelia/Model/Base/FeatureAvQuery.php index abdb2f497..193254a87 100644 --- a/core/lib/Thelia/Model/Base/FeatureAvQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureAvQuery.php @@ -796,7 +796,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureAvI18n'; @@ -814,7 +814,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -835,7 +835,7 @@ abstract class FeatureAvQuery extends ModelCriteria * * @return ChildFeatureAvI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/FeatureI18n.php b/core/lib/Thelia/Model/Base/FeatureI18n.php index b6070932e..0ede8eddb 100644 --- a/core/lib/Thelia/Model/Base/FeatureI18n.php +++ b/core/lib/Thelia/Model/Base/FeatureI18n.php @@ -61,7 +61,7 @@ abstract class FeatureI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class FeatureI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php index add0494aa..ba927a766 100644 --- a/core/lib/Thelia/Model/Base/FeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -931,7 +931,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FeatureI18n'; @@ -949,7 +949,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -970,7 +970,7 @@ abstract class FeatureQuery extends ModelCriteria * * @return ChildFeatureI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Folder.php b/core/lib/Thelia/Model/Base/Folder.php index a8bd93633..094ab27ba 100644 --- a/core/lib/Thelia/Model/Base/Folder.php +++ b/core/lib/Thelia/Model/Base/Folder.php @@ -186,7 +186,7 @@ abstract class Folder implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -3668,7 +3668,7 @@ abstract class Folder implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collImages instanceof Collection) { @@ -3734,7 +3734,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -3758,7 +3758,7 @@ abstract class Folder implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildFolderI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collFolderI18ns) { @@ -3793,7 +3793,7 @@ abstract class Folder implements ActiveRecordInterface * * @return ChildFolder The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildFolderI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/FolderI18n.php b/core/lib/Thelia/Model/Base/FolderI18n.php index 35e69d6a6..fcdc66705 100644 --- a/core/lib/Thelia/Model/Base/FolderI18n.php +++ b/core/lib/Thelia/Model/Base/FolderI18n.php @@ -61,7 +61,7 @@ abstract class FolderI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class FolderI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/FolderQuery.php b/core/lib/Thelia/Model/Base/FolderQuery.php index f7d84819d..101ab3974 100644 --- a/core/lib/Thelia/Model/Base/FolderQuery.php +++ b/core/lib/Thelia/Model/Base/FolderQuery.php @@ -1295,7 +1295,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'FolderI18n'; @@ -1313,7 +1313,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1334,7 +1334,7 @@ abstract class FolderQuery extends ModelCriteria * * @return ChildFolderI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php index 6b66d5f39..9cfde2bdc 100644 --- a/core/lib/Thelia/Model/Base/Group.php +++ b/core/lib/Thelia/Model/Base/Group.php @@ -139,7 +139,7 @@ abstract class Group implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2786,7 +2786,7 @@ abstract class Group implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collAdminGroups instanceof Collection) { @@ -2848,7 +2848,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2872,7 +2872,7 @@ abstract class Group implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildGroupI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collGroupI18ns) { @@ -2907,7 +2907,7 @@ abstract class Group implements ActiveRecordInterface * * @return ChildGroup The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildGroupI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php index de90d8863..4de63ea63 100644 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ b/core/lib/Thelia/Model/Base/GroupI18n.php @@ -61,7 +61,7 @@ abstract class GroupI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class GroupI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php index 8ca963848..d0eded79b 100644 --- a/core/lib/Thelia/Model/Base/GroupQuery.php +++ b/core/lib/Thelia/Model/Base/GroupQuery.php @@ -891,7 +891,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; @@ -909,7 +909,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -930,7 +930,7 @@ abstract class GroupQuery extends ModelCriteria * * @return ChildGroupI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Image.php b/core/lib/Thelia/Model/Base/Image.php index 50538aa1a..d19b557ab 100644 --- a/core/lib/Thelia/Model/Base/Image.php +++ b/core/lib/Thelia/Model/Base/Image.php @@ -159,7 +159,7 @@ abstract class Image implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2042,7 +2042,7 @@ abstract class Image implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collImageI18ns instanceof Collection) { @@ -2088,7 +2088,7 @@ abstract class Image implements ActiveRecordInterface * * @return ChildImage The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2112,7 +2112,7 @@ abstract class Image implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildImageI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collImageI18ns) { @@ -2147,7 +2147,7 @@ abstract class Image implements ActiveRecordInterface * * @return ChildImage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildImageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ImageI18n.php b/core/lib/Thelia/Model/Base/ImageI18n.php index 324f939e9..945605968 100644 --- a/core/lib/Thelia/Model/Base/ImageI18n.php +++ b/core/lib/Thelia/Model/Base/ImageI18n.php @@ -61,7 +61,7 @@ abstract class ImageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ImageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ImageQuery.php b/core/lib/Thelia/Model/Base/ImageQuery.php index 6e16a885b..b5b4bfd90 100644 --- a/core/lib/Thelia/Model/Base/ImageQuery.php +++ b/core/lib/Thelia/Model/Base/ImageQuery.php @@ -1175,7 +1175,7 @@ abstract class ImageQuery extends ModelCriteria * * @return ChildImageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ImageI18n'; @@ -1193,7 +1193,7 @@ abstract class ImageQuery extends ModelCriteria * * @return ChildImageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -1214,7 +1214,7 @@ abstract class ImageQuery extends ModelCriteria * * @return ChildImageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Message.php b/core/lib/Thelia/Model/Base/Message.php index f39e4ecbe..a2327f388 100644 --- a/core/lib/Thelia/Model/Base/Message.php +++ b/core/lib/Thelia/Model/Base/Message.php @@ -141,7 +141,7 @@ abstract class Message implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2056,7 +2056,7 @@ abstract class Message implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collMessageI18ns instanceof Collection) { @@ -2102,7 +2102,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2126,7 +2126,7 @@ abstract class Message implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildMessageI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collMessageI18ns) { @@ -2161,7 +2161,7 @@ abstract class Message implements ActiveRecordInterface * * @return ChildMessage The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildMessageI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/MessageI18n.php b/core/lib/Thelia/Model/Base/MessageI18n.php index 545e75244..4d1a532fe 100644 --- a/core/lib/Thelia/Model/Base/MessageI18n.php +++ b/core/lib/Thelia/Model/Base/MessageI18n.php @@ -61,7 +61,7 @@ abstract class MessageI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -105,7 +105,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -538,7 +538,7 @@ abstract class MessageI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/MessageQuery.php b/core/lib/Thelia/Model/Base/MessageQuery.php index 938a16aab..cf0155f36 100644 --- a/core/lib/Thelia/Model/Base/MessageQuery.php +++ b/core/lib/Thelia/Model/Base/MessageQuery.php @@ -913,7 +913,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'MessageI18n'; @@ -931,7 +931,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -952,7 +952,7 @@ abstract class MessageQuery extends ModelCriteria * * @return ChildMessageI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index ebe4b4c18..c1ee2ed8d 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -127,7 +127,7 @@ abstract class Module implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1910,7 +1910,7 @@ abstract class Module implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collGroupModules instanceof Collection) { @@ -1956,7 +1956,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1980,7 +1980,7 @@ abstract class Module implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildModuleI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { @@ -2015,7 +2015,7 @@ abstract class Module implements ActiveRecordInterface * * @return ChildModule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildModuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ModuleI18n.php b/core/lib/Thelia/Model/Base/ModuleI18n.php index 54cf305e4..fbb4293ba 100644 --- a/core/lib/Thelia/Model/Base/ModuleI18n.php +++ b/core/lib/Thelia/Model/Base/ModuleI18n.php @@ -61,7 +61,7 @@ abstract class ModuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ModuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index 7db21ca22..e1bd9de68 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -838,7 +838,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ModuleI18n'; @@ -856,7 +856,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -877,7 +877,7 @@ abstract class ModuleQuery extends ModelCriteria * * @return ChildModuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/OrderStatus.php b/core/lib/Thelia/Model/Base/OrderStatus.php index 15ce7fbf7..fc4a224d1 100644 --- a/core/lib/Thelia/Model/Base/OrderStatus.php +++ b/core/lib/Thelia/Model/Base/OrderStatus.php @@ -109,7 +109,7 @@ abstract class OrderStatus implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1812,7 +1812,7 @@ abstract class OrderStatus implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collOrders instanceof Collection) { @@ -1858,7 +1858,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1882,7 +1882,7 @@ abstract class OrderStatus implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildOrderStatusI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collOrderStatusI18ns) { @@ -1917,7 +1917,7 @@ abstract class OrderStatus implements ActiveRecordInterface * * @return ChildOrderStatus The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildOrderStatusI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/OrderStatusI18n.php b/core/lib/Thelia/Model/Base/OrderStatusI18n.php index 1f98739f0..76ec4a28a 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusI18n.php +++ b/core/lib/Thelia/Model/Base/OrderStatusI18n.php @@ -61,7 +61,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class OrderStatusI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/OrderStatusQuery.php b/core/lib/Thelia/Model/Base/OrderStatusQuery.php index 07fcdb8dc..908efd6b6 100644 --- a/core/lib/Thelia/Model/Base/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/Base/OrderStatusQuery.php @@ -703,7 +703,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'OrderStatusI18n'; @@ -721,7 +721,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -742,7 +742,7 @@ abstract class OrderStatusQuery extends ModelCriteria * * @return ChildOrderStatusI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Product.php b/core/lib/Thelia/Model/Base/Product.php index 29769aef9..a2a918107 100644 --- a/core/lib/Thelia/Model/Base/Product.php +++ b/core/lib/Thelia/Model/Base/Product.php @@ -287,7 +287,7 @@ abstract class Product implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -6096,7 +6096,7 @@ abstract class Product implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProductCategories instanceof Collection) { @@ -6191,7 +6191,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -6215,7 +6215,7 @@ abstract class Product implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildProductI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collProductI18ns) { @@ -6250,7 +6250,7 @@ abstract class Product implements ActiveRecordInterface * * @return ChildProduct The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildProductI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ProductI18n.php b/core/lib/Thelia/Model/Base/ProductI18n.php index 7b6e65976..b0c74bb54 100644 --- a/core/lib/Thelia/Model/Base/ProductI18n.php +++ b/core/lib/Thelia/Model/Base/ProductI18n.php @@ -61,7 +61,7 @@ abstract class ProductI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ProductI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ProductQuery.php b/core/lib/Thelia/Model/Base/ProductQuery.php index c4f2ce371..ebe26aa12 100644 --- a/core/lib/Thelia/Model/Base/ProductQuery.php +++ b/core/lib/Thelia/Model/Base/ProductQuery.php @@ -2110,7 +2110,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ProductI18n'; @@ -2128,7 +2128,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -2149,7 +2149,7 @@ abstract class ProductQuery extends ModelCriteria * * @return ChildProductI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index 827de2643..c6c527134 100644 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -116,7 +116,7 @@ abstract class Resource implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1968,7 +1968,7 @@ abstract class Resource implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collGroupResources instanceof Collection) { @@ -2018,7 +2018,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2042,7 +2042,7 @@ abstract class Resource implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildResourceI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collResourceI18ns) { @@ -2077,7 +2077,7 @@ abstract class Resource implements ActiveRecordInterface * * @return ChildResource The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildResourceI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/ResourceI18n.php b/core/lib/Thelia/Model/Base/ResourceI18n.php index b740bd858..c060e8776 100644 --- a/core/lib/Thelia/Model/Base/ResourceI18n.php +++ b/core/lib/Thelia/Model/Base/ResourceI18n.php @@ -61,7 +61,7 @@ abstract class ResourceI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -111,7 +111,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -576,7 +576,7 @@ abstract class ResourceI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php index e12ee8f53..6559d6522 100644 --- a/core/lib/Thelia/Model/Base/ResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceQuery.php @@ -720,7 +720,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'ResourceI18n'; @@ -738,7 +738,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -759,7 +759,7 @@ abstract class ResourceQuery extends ModelCriteria * * @return ChildResourceI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/Tax.php b/core/lib/Thelia/Model/Base/Tax.php index f3717366f..3e405414c 100644 --- a/core/lib/Thelia/Model/Base/Tax.php +++ b/core/lib/Thelia/Model/Base/Tax.php @@ -109,7 +109,7 @@ abstract class Tax implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -1762,7 +1762,7 @@ abstract class Tax implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collTaxRuleCountries instanceof Collection) { @@ -1808,7 +1808,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -1832,7 +1832,7 @@ abstract class Tax implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxI18ns) { @@ -1867,7 +1867,7 @@ abstract class Tax implements ActiveRecordInterface * * @return ChildTax The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxI18n.php b/core/lib/Thelia/Model/Base/TaxI18n.php index 8fdec086d..f8577e860 100644 --- a/core/lib/Thelia/Model/Base/TaxI18n.php +++ b/core/lib/Thelia/Model/Base/TaxI18n.php @@ -61,7 +61,7 @@ abstract class TaxI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -99,7 +99,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -500,7 +500,7 @@ abstract class TaxI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxQuery.php b/core/lib/Thelia/Model/Base/TaxQuery.php index 0a61cbb3c..307ace57c 100644 --- a/core/lib/Thelia/Model/Base/TaxQuery.php +++ b/core/lib/Thelia/Model/Base/TaxQuery.php @@ -715,7 +715,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxI18n'; @@ -733,7 +733,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -754,7 +754,7 @@ abstract class TaxQuery extends ModelCriteria * * @return ChildTaxI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Base/TaxRule.php b/core/lib/Thelia/Model/Base/TaxRule.php index 101471313..bf318498c 100644 --- a/core/lib/Thelia/Model/Base/TaxRule.php +++ b/core/lib/Thelia/Model/Base/TaxRule.php @@ -129,7 +129,7 @@ abstract class TaxRule implements ActiveRecordInterface * Current locale * @var string */ - protected $currentLocale = 'en_EN'; + protected $currentLocale = 'en_US'; /** * Current translation objects @@ -2146,7 +2146,7 @@ abstract class TaxRule implements ActiveRecordInterface } // if ($deep) // i18n behavior - $this->currentLocale = 'en_EN'; + $this->currentLocale = 'en_US'; $this->currentTranslations = null; if ($this->collProducts instanceof Collection) { @@ -2196,7 +2196,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function setLocale($locale = 'en_EN') + public function setLocale($locale = 'en_US') { $this->currentLocale = $locale; @@ -2220,7 +2220,7 @@ abstract class TaxRule implements ActiveRecordInterface * @param ConnectionInterface $con an optional connection object * * @return ChildTaxRuleI18n */ - public function getTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collTaxRuleI18ns) { @@ -2255,7 +2255,7 @@ abstract class TaxRule implements ActiveRecordInterface * * @return ChildTaxRule The current object (for fluent API support) */ - public function removeTranslation($locale = 'en_EN', ConnectionInterface $con = null) + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!$this->isNew()) { ChildTaxRuleI18nQuery::create() diff --git a/core/lib/Thelia/Model/Base/TaxRuleI18n.php b/core/lib/Thelia/Model/Base/TaxRuleI18n.php index 86215b335..51bab6a77 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleI18n.php +++ b/core/lib/Thelia/Model/Base/TaxRuleI18n.php @@ -61,7 +61,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface /** * The value for the locale field. - * Note: this column has a database default value of: 'en_EN' + * Note: this column has a database default value of: 'en_US' * @var string */ protected $locale; @@ -87,7 +87,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function applyDefaultValues() { - $this->locale = 'en_EN'; + $this->locale = 'en_US'; } /** @@ -424,7 +424,7 @@ abstract class TaxRuleI18n implements ActiveRecordInterface */ public function hasOnlyDefaultValues() { - if ($this->locale !== 'en_EN') { + if ($this->locale !== 'en_US') { return false; } diff --git a/core/lib/Thelia/Model/Base/TaxRuleQuery.php b/core/lib/Thelia/Model/Base/TaxRuleQuery.php index 36f2edd99..2fb478b7a 100644 --- a/core/lib/Thelia/Model/Base/TaxRuleQuery.php +++ b/core/lib/Thelia/Model/Base/TaxRuleQuery.php @@ -846,7 +846,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinI18n($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $relationName = $relationAlias ? $relationAlias : 'TaxRuleI18n'; @@ -864,7 +864,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleQuery The current query, for fluid interface */ - public function joinWithI18n($locale = 'en_EN', $joinType = Criteria::LEFT_JOIN) + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) { $this ->joinI18n($locale, null, $joinType) @@ -885,7 +885,7 @@ abstract class TaxRuleQuery extends ModelCriteria * * @return ChildTaxRuleI18nQuery A secondary query class using the current class as primary query */ - public function useI18nQuery($locale = 'en_EN', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this ->joinI18n($locale, $relationAlias, $joinType) diff --git a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php index 14fc79eeb..02a20540e 100644 --- a/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php index 138f0fa9c..0c5c2e1c9 100644 --- a/core/lib/Thelia/Model/Map/AttributeAvTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeAvTableMap.php @@ -106,7 +106,7 @@ class AttributeAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php index b60cae5b8..8471d3e26 100644 --- a/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeI18nTableMap.php @@ -151,7 +151,7 @@ class AttributeI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'attribute', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index dca811cbc..773e13cab 100644 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -101,7 +101,7 @@ class AttributeTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php index 1611b2ebf..8c52aa7b2 100644 --- a/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryI18nTableMap.php @@ -151,7 +151,7 @@ class CategoryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'category', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CategoryTableMap.php b/core/lib/Thelia/Model/Map/CategoryTableMap.php index 83010e4fa..a301a5efe 100644 --- a/core/lib/Thelia/Model/Map/CategoryTableMap.php +++ b/core/lib/Thelia/Model/Map/CategoryTableMap.php @@ -131,7 +131,7 @@ class CategoryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php index a83f87b76..b953b0ac9 100644 --- a/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigI18nTableMap.php @@ -151,7 +151,7 @@ class ConfigI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'config', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ConfigTableMap.php b/core/lib/Thelia/Model/Map/ConfigTableMap.php index 8bd68a964..ebd5d6edf 100644 --- a/core/lib/Thelia/Model/Map/ConfigTableMap.php +++ b/core/lib/Thelia/Model/Map/ConfigTableMap.php @@ -116,7 +116,7 @@ class ConfigTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php index ee9122a6c..f718623b0 100644 --- a/core/lib/Thelia/Model/Map/ContentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentI18nTableMap.php @@ -151,7 +151,7 @@ class ContentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'content', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ContentTableMap.php b/core/lib/Thelia/Model/Map/ContentTableMap.php index 60b04ae36..b794c7244 100644 --- a/core/lib/Thelia/Model/Map/ContentTableMap.php +++ b/core/lib/Thelia/Model/Map/ContentTableMap.php @@ -121,7 +121,7 @@ class ContentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php index cc60b09d2..272231464 100644 --- a/core/lib/Thelia/Model/Map/CountryI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryI18nTableMap.php @@ -151,7 +151,7 @@ class CountryI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'country', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/CountryTableMap.php b/core/lib/Thelia/Model/Map/CountryTableMap.php index c4b96c8bd..3060da70f 100644 --- a/core/lib/Thelia/Model/Map/CountryTableMap.php +++ b/core/lib/Thelia/Model/Map/CountryTableMap.php @@ -116,7 +116,7 @@ class CountryTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php index d403756fa..5344099c5 100644 --- a/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleI18nTableMap.php @@ -141,7 +141,7 @@ class CustomerTitleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'customer_title', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('SHORT', 'Short', 'VARCHAR', false, 10, null); $this->addColumn('LONG', 'Long', 'VARCHAR', false, 45, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php index a392ee4dd..8e91631cf 100644 --- a/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php +++ b/core/lib/Thelia/Model/Map/CustomerTitleTableMap.php @@ -106,7 +106,7 @@ class CustomerTitleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php index d0356e8c6..70314ea02 100644 --- a/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/DocumentI18nTableMap.php @@ -151,7 +151,7 @@ class DocumentI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'document', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/DocumentTableMap.php b/core/lib/Thelia/Model/Map/DocumentTableMap.php index 50bb37b95..d53263a06 100644 --- a/core/lib/Thelia/Model/Map/DocumentTableMap.php +++ b/core/lib/Thelia/Model/Map/DocumentTableMap.php @@ -126,7 +126,7 @@ class DocumentTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php index b3114e7ba..ba592b4b0 100644 --- a/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureAvI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature_av', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php index f447f8dc5..972a25744 100644 --- a/core/lib/Thelia/Model/Map/FeatureAvTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureAvTableMap.php @@ -101,7 +101,7 @@ class FeatureAvTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php index af0dfc263..dba05fb67 100644 --- a/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureI18nTableMap.php @@ -151,7 +151,7 @@ class FeatureI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'feature', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 8d851559e..b1f309603 100644 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -106,7 +106,7 @@ class FeatureTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php index fc85b17ec..d10344811 100644 --- a/core/lib/Thelia/Model/Map/FolderI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderI18nTableMap.php @@ -151,7 +151,7 @@ class FolderI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'folder', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/FolderTableMap.php b/core/lib/Thelia/Model/Map/FolderTableMap.php index 794e3691c..c26e23dc8 100644 --- a/core/lib/Thelia/Model/Map/FolderTableMap.php +++ b/core/lib/Thelia/Model/Map/FolderTableMap.php @@ -131,7 +131,7 @@ class FolderTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php index 585127821..57788593a 100644 --- a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php @@ -151,7 +151,7 @@ class GroupI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php index a8c830005..881a2fa84 100644 --- a/core/lib/Thelia/Model/Map/GroupTableMap.php +++ b/core/lib/Thelia/Model/Map/GroupTableMap.php @@ -101,7 +101,7 @@ class GroupTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php index 4f3b197a6..a78e7667c 100644 --- a/core/lib/Thelia/Model/Map/ImageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ImageI18nTableMap.php @@ -151,7 +151,7 @@ class ImageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'image', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ImageTableMap.php b/core/lib/Thelia/Model/Map/ImageTableMap.php index 0f8d82b20..c49f24527 100644 --- a/core/lib/Thelia/Model/Map/ImageTableMap.php +++ b/core/lib/Thelia/Model/Map/ImageTableMap.php @@ -126,7 +126,7 @@ class ImageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php index f084515c0..bb9bfdd2e 100644 --- a/core/lib/Thelia/Model/Map/MessageI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageI18nTableMap.php @@ -146,7 +146,7 @@ class MessageI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'message', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'LONGVARCHAR', false, null, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('DESCRIPTION_HTML', 'DescriptionHtml', 'CLOB', false, null, null); diff --git a/core/lib/Thelia/Model/Map/MessageTableMap.php b/core/lib/Thelia/Model/Map/MessageTableMap.php index de2a205f9..392dac824 100644 --- a/core/lib/Thelia/Model/Map/MessageTableMap.php +++ b/core/lib/Thelia/Model/Map/MessageTableMap.php @@ -126,7 +126,7 @@ class MessageTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php index 67b7a34ef..a8e680f1c 100644 --- a/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleI18nTableMap.php @@ -151,7 +151,7 @@ class ModuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'module', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index 5370c1da1..cccaa890a 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -116,7 +116,7 @@ class ModuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php index 5d78c474c..1b2052c2e 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusI18nTableMap.php @@ -151,7 +151,7 @@ class OrderStatusI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'order_status', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php index eecfe5a03..18406d9aa 100644 --- a/core/lib/Thelia/Model/Map/OrderStatusTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderStatusTableMap.php @@ -101,7 +101,7 @@ class OrderStatusTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php index 8da33f15d..79a01514a 100644 --- a/core/lib/Thelia/Model/Map/ProductI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductI18nTableMap.php @@ -151,7 +151,7 @@ class ProductI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'product', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ProductTableMap.php b/core/lib/Thelia/Model/Map/ProductTableMap.php index b009a97af..40200ce10 100644 --- a/core/lib/Thelia/Model/Map/ProductTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductTableMap.php @@ -166,7 +166,7 @@ class ProductTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php index 8a8ce501a..ec22e2fd3 100644 --- a/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceI18nTableMap.php @@ -151,7 +151,7 @@ class ResourceI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php index e56960892..8d7708ddd 100644 --- a/core/lib/Thelia/Model/Map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -101,7 +101,7 @@ class ResourceTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php index 2c4c92f4f..a06230c37 100644 --- a/core/lib/Thelia/Model/Map/TaxI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxI18nTableMap.php @@ -141,7 +141,7 @@ class TaxI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'LONGVARCHAR', false, null, null); } // initialize() diff --git a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php index 689f30728..1f0ed1e96 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleI18nTableMap.php @@ -131,7 +131,7 @@ class TaxRuleI18nTableMap extends TableMap $this->setUseIdGenerator(false); // columns $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'tax_rule', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_EN'); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); } // initialize() /** diff --git a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php index 9b862de99..cc5f628b9 100644 --- a/core/lib/Thelia/Model/Map/TaxRuleTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxRuleTableMap.php @@ -111,7 +111,7 @@ class TaxRuleTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames diff --git a/core/lib/Thelia/Model/Map/TaxTableMap.php b/core/lib/Thelia/Model/Map/TaxTableMap.php index b941e7b52..6d43f20e9 100644 --- a/core/lib/Thelia/Model/Map/TaxTableMap.php +++ b/core/lib/Thelia/Model/Map/TaxTableMap.php @@ -101,7 +101,7 @@ class TaxTableMap extends TableMap * * @var string */ - const DEFAULT_LOCALE = 'en_EN'; + const DEFAULT_LOCALE = 'en_US'; /** * holds an array of fieldnames From e0416c08f86383ca87b7244a8e2b14e678f120cb Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 5 Jul 2013 12:13:28 +0200 Subject: [PATCH 34/35] fix broken test --- core/lib/Thelia/Core/Thelia.php | 28 -------------------------- core/lib/Thelia/Tests/Log/TlogTest.php | 4 +--- 2 files changed, 1 insertion(+), 31 deletions(-) diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 6008939fb..63366c208 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -71,34 +71,6 @@ class Thelia extends Kernel return ; } -/* if (! Propel::isInit()) { - - $definePropel = new DefinePropel(new DatabaseConfiguration(), - Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); - - Propel::setConfiguration($definePropel->getConfig()); - - if ($this->isDebug()) { - Propel::setLogger(Tlog::getInstance()); - $config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT); - $config->setParameter('debugpdo.logging.methods', array( - 'PropelPDO::exec', - 'PropelPDO::query', - 'PropelPDO::prepare', - 'DebugPDOStatement::execute', - ), false); - $config->setParameter('debugpdo.logging.details', array( - 'time' => array('enabled' => true), - 'mem' => array('enabled' => true), - 'connection' => array('enabled' => true), - )); - $con = Propel::getConnection("thelia"); - $con->useDebug(true); - } - - Propel::initialize(); - }*/ - $definePropel = new DefinePropel(new DatabaseConfiguration(), Yaml::parse(THELIA_ROOT . '/local/config/database.yml')); $propelConfig = $definePropel->getConfig(); diff --git a/core/lib/Thelia/Tests/Log/TlogTest.php b/core/lib/Thelia/Tests/Log/TlogTest.php index 14518e5ce..acae68dc6 100755 --- a/core/lib/Thelia/Tests/Log/TlogTest.php +++ b/core/lib/Thelia/Tests/Log/TlogTest.php @@ -33,9 +33,7 @@ class TlogTest extends \PHPUnit_Framework_TestCase public static function setUpBeforeClass() { - if (!\Propel::isInit()){ - \Propel::init(THELIA_ROOT . "/local/config/config_thelia.php"); - } + self::$logger = Tlog::getInstance(); From a2012259bfe9e9a2dd599923c5c17c5673428f5a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 5 Jul 2013 12:57:04 +0200 Subject: [PATCH 35/35] change getting propel connection --- core/lib/Thelia/Core/Thelia.php | 2 +- install/faker.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php index 63366c208..b023a4eab 100755 --- a/core/lib/Thelia/Core/Thelia.php +++ b/core/lib/Thelia/Core/Thelia.php @@ -83,7 +83,7 @@ class Thelia extends Kernel if ($this->isDebug()) { $serviceContainer->setLogger('defaultLogger', Tlog::getInstance()); - $con = Propel::getConnection("thelia"); + $con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $con->useDebug(true); } } diff --git a/install/faker.php b/install/faker.php index de6f6fdfb..925e83e5c 100755 --- a/install/faker.php +++ b/install/faker.php @@ -5,7 +5,7 @@ $thelia = new Thelia\Core\Thelia("dev", true); $faker = Faker\Factory::create(); -$con = \Propel::getConnection(Thelia\Model\ProductPeer::DATABASE_NAME); +$con = \Propel\Runtime\Propel::getConnection(Thelia\Model\Map\ProductTableMap::DATABASE_NAME); $con->beginTransaction(); try {